lemon: fix memleak in ReportTable
authorPeter Wu <peter@lekensteyn.nl>
Sat, 20 Oct 2018 19:38:39 +0000 (21:38 +0200)
committerAnders Broman <a.broman58@gmail.com>
Sun, 21 Oct 2018 06:58:32 +0000 (06:58 +0000)
Building without -DENABLE_ASAN=1 but with -fsanitize=address (as is done
by oss-fuzz) still triggers a memleak report. Closer inspection revealed
that two other members were leaked.

Change-Id: I3d022ac50c554891a73b9380b7879c1a60c3c798
Reviewed-on: https://code.wireshark.org/review/30289
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
tools/lemon/lemon.c

index faa85308706493934aaa058e79af94835b18c4c4..f2e541a549b95af87c12d5810e9df4f9e008ece2 100644 (file)
@@ -615,13 +615,11 @@ struct acttab {
 #define acttab_yylookahead(X,N)  ((X)->aAction[N].lookahead)
 
 /* Free all memory associated with the given acttab */
-#if 0
 PRIVATE void acttab_free(acttab *p){
   free( p->aAction );
   free( p->aLookahead );
   free( p );
 }
-#endif
 
 /* Allocate a new acttab structure */
 PRIVATE acttab *acttab_alloc(int nsymbol, int nterminal) {
@@ -4436,7 +4434,7 @@ void ReportTable(
     }
   }
   fprintf(out, "};\n"); lineno++;
-  free(pActtab);
+  acttab_free(pActtab);
 
   /* Output the yy_shift_ofst[] table */
   n = lemp->nxstate;