home · contact · privacy
Improved and defined more precisely textfile_sizes().
[plomrogue] / src / keybindings.c
index 3ce0e440b2d319af9ff0b81d1040bc468518c10f..8b01958c940d5079f4d5157b6034a92f918a056e 100644 (file)
@@ -21,10 +21,10 @@ extern void init_keybindings(struct World * world)
     char * err = "textfile_sizes() in init_keybindings() returns error.";
     exit_err(textfile_sizes(file, &linemax, &lines), world, err);
     struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
-    char * command = malloc(linemax);
+    char * command = malloc(linemax + 1);
     uint16_t commcount = 0;
     char * cmdptr;
-    while (fgets(command, linemax, file))
+    while (fgets(command, linemax + 1, file))
     {
         keybindings[commcount].key = atoi(command);
         cmdptr = strchr(command, ' ') + 1;