]> git.saurik.com Git - bison.git/blobdiff - data/push.c
Fix push parsing memory leak reported by Brandon Lucia at
[bison.git] / data / push.c
index ee9aa671432318e15ffedda98fbf5ce642845360..c72d1573e4e787e15f57ccad05c685152743a0a4 100644 (file)
@@ -1124,6 +1124,12 @@ b4_push_if(
 ]b4_c_function_def([[yypstate_delete]], [[void]],
                    [[[yypstate *yyps]], [[yyps]]])[
 {
 ]b4_c_function_def([[yypstate_delete]], [[void]],
                    [[[yypstate *yyps]], [[yyps]]])[
 {
+#ifndef yyoverflow
+  /* If the stack was reallocated but the parse did not complete, then the
+     stack still needs to be freed.  */
+  if (!yyps->yynew && yyps->yyss != yyps->yyssa)
+    YYSTACK_FREE (yyps->yyss);
+#endif
   free (yyps);
 }
 
   free (yyps);
 }