diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-30 16:59:39 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-30 16:59:39 +0000 |
commit | ad37de5ea29c316c3549a32e1f0b8ac1c16f0967 (patch) | |
tree | 3a112b525dcdedaf4ac24acf562a22feec33f238 /sbin/pfctl/parse.y | |
parent | 6fcea06b57b5971202f277427c4dead51ca8dfbb (diff) |
fix TAILQ abuse.
TAILQ_REMOVE is a no-no within a TAILQ_FOREACH loop.
also free the symbol itself after removal.
all found while hacking bgpd which incorporates pfctl's sym code (macros).
ok cedric@
Diffstat (limited to 'sbin/pfctl/parse.y')
-rw-r--r-- | sbin/pfctl/parse.y | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 420bdd07343..b869827cbca 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.431 2003/12/19 16:12:43 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.432 2003/12/30 16:59:38 henning Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -4392,7 +4392,7 @@ top: int parse_rules(FILE *input, struct pfctl *xpf) { - struct sym *sym; + struct sym *sym, *next; fin = input; pf = xpf; @@ -4408,13 +4408,15 @@ parse_rules(FILE *input, struct pfctl *xpf) 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 ((pf->opts & PF_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); } return (errors ? -1 : 0); |