* tests/push.at (Push Parsing: Memory Leak for Early Deletion): Do not

name user variables starting with `yy'.  Just pass NULL instead of a
dummy local &yylval to yypush_parse.
* tests/torture.at (AT_DATA_STACK_TORTURE): Do not name user variables
starting with `yy'.
This commit is contained in:
Joel E. Denny
2007-08-11 23:08:04 +00:00
parent 91661ebbe3
commit 5d31a2162d
3 changed files with 24 additions and 18 deletions

View File

@@ -1,3 +1,11 @@
2007-08-11 Joel E. Denny <jdenny@ces.clemson.edu>
* tests/push.at (Push Parsing: Memory Leak for Early Deletion): Do not
name user variables starting with `yy'. Just pass NULL instead of a
dummy local &yylval to yypush_parse.
* tests/torture.at (AT_DATA_STACK_TORTURE): Do not name user variables
starting with `yy'.
2007-08-03 Joel E. Denny <jdenny@ces.clemson.edu> 2007-08-03 Joel E. Denny <jdenny@ces.clemson.edu>
* data/yacc.c (yyexhaustedlab): Define it when YYERROR_VERBOSE is * data/yacc.c (yyexhaustedlab): Define it when YYERROR_VERBOSE is

View File

@@ -52,24 +52,22 @@ yyerror (char const *msg)
int int
main (void) main (void)
{ {
yypstate *yyps; yypstate *ps;
YYSTYPE yylval;
/* Make sure we don't try to free yyps->yyss in this case. */ /* Make sure we don't try to free ps->yyss in this case. */
yyps = yypstate_new (); ps = yypstate_new ();
yypstate_delete (yyps); yypstate_delete (ps);
/* yypstate_delete used to leak yyps->yyss if the stack was reallocated but /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
the parse did not return on success, syntax error, or memory parse did not return on success, syntax error, or memory exhaustion. */
exhaustion. */ ps = yypstate_new ();
yyps = yypstate_new (); assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
assert (yypush_parse (yyps, 'a', &yylval) == YYPUSH_MORE); yypstate_delete (ps);
yypstate_delete (yyps);
yyps = yypstate_new (); ps = yypstate_new ();
assert (yypush_parse (yyps, 'a', &yylval) == YYPUSH_MORE); assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
assert (yypush_parse (yyps, 'b', &yylval) == YYPUSH_MORE); assert (yypush_parse (ps, 'b', NULL) == YYPUSH_MORE);
yypstate_delete (yyps); yypstate_delete (ps);
return 0; return 0;
} }

View File

@@ -444,13 +444,13 @@ main (int argc, const char **argv)
int count; int count;
int status; int status;
]m4_bmatch([$2], [%push-], ]m4_bmatch([$2], [%push-],
[[ yypstate *yyps = yypstate_new (); [[ yypstate *ps = yypstate_new ();
]])[ for (count = 0; count < 2; ++count) ]])[ for (count = 0; count < 2; ++count)
{ {
int new_status; int new_status;
yylval = yylval_init; yylval = yylval_init;
]m4_bmatch([$2], [%push-], ]m4_bmatch([$2], [%push-],
[[ new_status = yypull_parse (yyps); [[ new_status = yypull_parse (ps);
]], ]],
[[ new_status = yyparse (); [[ new_status = yyparse ();
]])[ if (count > 0 && new_status != status) ]])[ if (count > 0 && new_status != status)
@@ -458,7 +458,7 @@ main (int argc, const char **argv)
status = new_status; status = new_status;
} }
]m4_bmatch([$2], [%push-], ]m4_bmatch([$2], [%push-],
[[ yypstate_delete (yyps); [[ yypstate_delete (ps);
]])[ return status; ]])[ return status;
} }
} }