[tarantool-patches] [PATCH] sql: fix lemon memory leak reported by ASAN

Alexander Turenko alexander.turenko at tarantool.org
Sat Jan 5 16:13:58 MSK 2019


It catched by ASAN at build time (lemon is executed to generate
parse.[ch]), so tarantool couldn't be built with -DENABLE_ASAN=ON.
---

no issue
https://github.com/tarantool/tarantool/tree/Totktonada/fix-lemon-memleak

 extra/lemon.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/extra/lemon.c b/extra/lemon.c
index 66e425f68..1efaac9e6 100644
--- a/extra/lemon.c
+++ b/extra/lemon.c
@@ -598,8 +598,11 @@ struct acttab {
 
 /* Free all memory associated with the given acttab */
 void acttab_free(acttab *p){
-  free( p->aAction );
-  free( p->aLookahead );
+  assert(p);
+  if (p->aAction)
+    free( p->aAction );
+  if (p->aLookahead)
+    free( p->aLookahead );
   free( p );
 }
 
@@ -4255,6 +4258,7 @@ void ReportTable(
     }
   }
   fprintf(out, "};\n"); lineno++;
+  acttab_free(pActtab);
 
   /* Output the yy_shift_ofst[] table */
   n = lemp->nxstate;
-- 
2.20.1





More information about the Tarantool-patches mailing list