From 1531c601ab2f2a4d54d2425d97bfc4665c04a67c Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Fri, 12 Mar 2004 13:39:51 +0000 Subject: fix memory leak in the code yacc generates, ok millert deraadt --- usr.bin/yacc/skeleton.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/usr.bin/yacc/skeleton.c b/usr.bin/yacc/skeleton.c index 9329ccf9e93..a6e17d47a22 100644 --- a/usr.bin/yacc/skeleton.c +++ b/usr.bin/yacc/skeleton.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeleton.c,v 1.22 2003/11/25 20:00:15 espie Exp $ */ +/* $OpenBSD: skeleton.c,v 1.23 2004/03/12 13:39:50 henning Exp $ */ /* $NetBSD: skeleton.c,v 1.10 1996/03/25 00:36:18 mrg Exp $ */ /* @@ -63,7 +63,7 @@ char *banner[] = "#if __GNUC__ >= 2", " __attribute__ ((unused))", "#endif /* __GNUC__ >= 2 */", - " = \"$OpenBSD: skeleton.c,v 1.22 2003/11/25 20:00:15 espie Exp $\";", + " = \"$OpenBSD: skeleton.c,v 1.23 2004/03/12 13:39:50 henning Exp $\";", "#endif", "#include ", "#define YYBYACC 1", @@ -397,8 +397,22 @@ char *trailer[] = "yyoverflow:", " yyerror(\"yacc stack overflow\");", "yyabort:", + " if (yyss)", + " free(yyss);", + " if (yyvs)", + " free(yyvs);", + " yyss = yyssp = NULL;", + " yyvs = yyvsp = NULL;", + " yystacksize = 0;", " return (1);", "yyaccept:", + " if (yyss)", + " free(yyss);", + " if (yyvs)", + " free(yyvs);", + " yyss = yyssp = NULL;", + " yyvs = yyvsp = NULL;", + " yystacksize = 0;", " return (0);", "}", 0 -- cgit v1.2.3