summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-03-12 13:39:51 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-03-12 13:39:51 +0000
commit1531c601ab2f2a4d54d2425d97bfc4665c04a67c (patch)
treea79d8c7c5c302a0ef89f601a702cac212d044296
parentde2f2f35ddc104a831c2ef44d1ac1b3f19d4a8a5 (diff)
fix memory leak in the code yacc generates, ok millert deraadt
-rw-r--r--usr.bin/yacc/skeleton.c18
1 files 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 <stdlib.h>",
"#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