home · contact · privacy
Forgot to allocate one byte for string-terminating null byte.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 1 May 2013 02:52:32 +0000 (04:52 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 1 May 2013 02:52:32 +0000 (04:52 +0200)
roguelike.c

index ee5dbe48be76fa54e3e9f7cafd2993a0c13404d6..34f3c855da6c9d2927bfad84e73ff11fe207f4e7 100644 (file)
@@ -262,7 +262,7 @@ void init_keybindings(struct World * world) {
   c = getc(file);
   while (EOF != c) {
     if ('\n' == c) {
-      keybindings[keycount].name = calloc(commcount, sizeof(char));
+      keybindings[keycount].name = calloc(commcount + 1, sizeof(char));
       memcpy(keybindings[keycount].name, command, commcount);
       keybindings[keycount].key = key;
       keycount++;