]> granicus.if.org Git - nethack/commitdiff
Fix lev_comp memory leaks
authorPasi Kallinen <paxed@alt.org>
Sat, 31 Oct 2015 22:28:28 +0000 (00:28 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 31 Oct 2015 22:28:28 +0000 (00:28 +0200)
util/lev_comp.y

index 5d777d44d70f31b2db273b50eb17d5a6ac7b2d9b..91d46a16191b76871c244b0aee17cda8d1fb1c07 100644 (file)
@@ -1518,6 +1518,7 @@ seen_trap_mask    : STRING
                      int token = get_trap_type($1);
                      if (token == ERR || token == 0)
                          lc_error("Unknown trap type '%s'!", $1);
+                      Free($1);
                      $$ = (1L << (token - 1));
                  }
                | ALL_ID
@@ -1532,7 +1533,7 @@ seen_trap_mask    : STRING
 
                      if ((1L << (token - 1)) & $3)
                          lc_error("Monster seen_traps, trap '%s' listed twice.", $1);
-
+                      Free($1);
                      $$ = ((1L << (token - 1)) | $3);
                  }
                ;
@@ -2205,6 +2206,7 @@ encodemonster     : STRING
                           $$ = -1;
                       } else
                           $$ = SP_MONST_PACK(m, def_monsyms[(int)mons[m].mlet].sym);
+                      Free($1);
                   }
                 | CHAR
                   {
@@ -2223,6 +2225,7 @@ encodemonster     : STRING
                           $$ = -1;
                       } else
                           $$ = SP_MONST_PACK(m, $2);
+                      Free($4);
                   }
                 | RANDOM_TYPE
                   {
@@ -2258,7 +2261,7 @@ encodeobj : STRING
                          $$ = -1;
                      } else
                          $$ = SP_OBJ_PACK(m, 1); /* obj class != 0 to force generation of a specific item */
-
+                      Free($1);
                  }
                | CHAR
                  {
@@ -2277,6 +2280,7 @@ encodeobj : STRING
                          $$ = -1;
                      } else
                          $$ = SP_OBJ_PACK(m, $2);
+                      Free($4);
                  }
                | RANDOM_TYPE
                  {