From 6002ef089c09188d3802adcc12fc5362c4427649 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Wed, 13 Apr 2005 21:16:23 +0000 Subject: filter_set cleanup. Plug some memleaks and fix an obvious bug in the network case. OK henning@ --- usr.sbin/bgpd/parse.y | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'usr.sbin/bgpd') diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index a2d47a30084..ea65f2c9053 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.158 2005/04/12 14:32:00 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.159 2005/04/13 21:16:22 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -334,8 +334,12 @@ conf_main : AS asnumber { memcpy(&n->net.prefix, &$2.prefix, sizeof(n->net.prefix)); n->net.prefixlen = $2.len; - memcpy(&n->net.attrset, &$3, - sizeof(n->net.attrset)); + if ($3 == NULL || SIMPLEQ_EMPTY($3)) + SIMPLEQ_INIT(&n->net.attrset); + else + memcpy(&n->net.attrset, $3, + sizeof(n->net.attrset)); + free($3); TAILQ_INSERT_TAIL(netconf, n, entry); } @@ -2040,6 +2044,7 @@ expand_rule(struct filter_rule *rule, struct filter_peers_l *peer, struct filter_peers_l *p, *pnext; struct filter_prefix_l *prefix, *prefix_next; struct filter_as_l *a, *anext; + struct filter_set *s; p = peer; do { @@ -2099,6 +2104,13 @@ expand_rule(struct filter_rule *rule, struct filter_peers_l *peer, anext = a->next; free(a); } + + while ((s = SIMPLEQ_FIRST(set)) != NULL) { + SIMPLEQ_REMOVE_HEAD(set, entry); + free(s); + } + free(set); + return (0); } -- cgit v1.2.3