From 428d5bffb0753c255bd3a6e7451b227979e281ec Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Tue, 26 Feb 2008 20:06:15 +0000 Subject: Fix memory leak in the parser. Found by Matthew Dempsky but using the more common way to clear the TAILQ. OK thib@ --- usr.sbin/snmpd/parse.y | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'usr.sbin/snmpd') diff --git a/usr.sbin/snmpd/parse.y b/usr.sbin/snmpd/parse.y index 75f03ec1e06..601ebdbcb66 100644 --- a/usr.sbin/snmpd/parse.y +++ b/usr.sbin/snmpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.11 2008/01/30 10:12:45 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.12 2008/02/26 20:06:14 claudio Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter @@ -170,6 +170,11 @@ main : LISTEN ON STRING { h = TAILQ_FIRST(&al); bcopy(&h->ss, &conf->sc_address.ss, sizeof(*h)); conf->sc_address.port = h->port; + + while ((h = TAILQ_FIRST(&al)) != NULL) { + TAILQ_REMOVE(&al, h, entry); + free(h); + } } | READONLY COMMUNITY STRING { if (strlcpy(conf->sc_rdcommunity, $3, -- cgit v1.2.3