[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bison 1.30: memory leak in yyparse
From: |
Per Allansson |
Subject: |
Bison 1.30: memory leak in yyparse |
Date: |
Thu, 08 Nov 2001 17:15:48 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011012 |
Hi,
I am using bison 1.30 on HP-UX 11.00. There is a memory
leak in yyparse (unless alloca is used of course) if the stacks
need to be expanded more than once - the old stacks must be freed -
see patch below.
/Per (address@hidden)
--- bison.simple.orig Wed Oct 10 17:04:56 2001
+++ bison.simple Thu Nov 8 16:45:55 2001
@@ -429,10 +429,20 @@
yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
__yy_memcpy ((char *)yyvs, (char *)yyvs1,
size * (unsigned int) sizeof (*yyvsp));
+# if !YYSTACK_USE_ALLOCA
+ if (yyss1 != yyssa)
+ free (yyss1);
+ if (yyvs1 != yyvsa)
+ free (yyvs1);
+# endif
# if YYLSP_NEEDED
yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
__yy_memcpy ((char *)yyls, (char *)yyls1,
size * (unsigned int) sizeof (*yylsp));
+# endif
+# if !YYSTACK_USE_ALLOCA
+ if (yyls1 != yylsa)
+ free (yyls1);
# endif
#endif /* no yyoverflow */
- Bison 1.30: memory leak in yyparse,
Per Allansson <=