X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=src%2Fcommand_db.c;h=bdcdcd1fa83a49faa343231360f4f72add0b4bcf;hb=0568c1c0f6735509f2a1afea31ecb5dc28f26bf4;hp=d5af5c27f8bdf8f6944f384f790e931168bc3d45;hpb=2f0b15e05b0df7e10a2d0bb04ce4648455d980a8;p=plomrogue diff --git a/src/command_db.c b/src/command_db.c index d5af5c2..bdcdcd1 100644 --- a/src/command_db.c +++ b/src/command_db.c @@ -87,12 +87,12 @@ extern void init_command_db(struct World * world) exit_err(NULL == file, world, err_o); uint16_t lines, linemax; exit_err(textfile_sizes(file, &linemax, &lines), world, err_s); + char line[linemax + 1]; - char line[linemax]; struct Command * cmds = malloc(lines * sizeof(struct Command)); exit_err(NULL == line, world, err_m); uint8_t i = 0; - while (fgets(line, linemax, file)) + while (fgets(line, linemax + 1, file)) { cmds[i].id = atoi(strtok(line, " ")); copy_tokenized_string(world, &cmds[i].dsc_short, " ", err_m);