summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-25 17:58:51 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-25 17:58:51 +0000
commit49a19b317169ad5c6d484ee8329e9129885c49a8 (patch)
tree60221de9295459d63ad9f7bdfb6ed333cb7fc490
parent42c50c6e9ab73fa714835314bf7d258f276154f5 (diff)
o can't TAILQ_FOREACH when we TAILQ_REMOVE in the loop
o free(sym)
-rw-r--r--usr.sbin/bgpd/parse.y8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index f2a4c5d7d23..76b4cb9fbe7 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.14 2003/12/25 17:35:53 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.15 2003/12/25 17:58:50 henning Exp $ */
/*
* Copyright (c) 2002, 2003 Henning Brauer <henning@openbsd.org>
@@ -530,7 +530,7 @@ int
parse_config(char *filename, struct bgpd_config *xconf,
struct mrt_config *xmconf)
{
- struct sym *sym;
+ struct sym *sym, *next;
if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL)
fatal(NULL, errno);
@@ -562,13 +562,15 @@ parse_config(char *filename, struct bgpd_config *xconf,
yyparse();
/* Free macros and check which have not been used. */
- TAILQ_FOREACH(sym, &symhead, entries) {
+ for(sym = TAILQ_FIRST(&symhead); sym != NULL; sym = next) {
+ next = TAILQ_NEXT(sym, entries);
if ((conf->opts & BGPD_OPT_VERBOSE2) && !sym->used)
fprintf(stderr, "warning: macro '%s' not "
"used\n", sym->nam);
free(sym->nam);
free(sym->val);
TAILQ_REMOVE(&symhead, sym, entries);
+ free(sym);
}
errors += merge_config(xconf, conf);