From a5624f2cf83218e1f61fc8e0c3fee211539e6c6a Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Wed, 20 May 2009 14:36:56 +0000 Subject: replace a TAILQ_FOREACH loop with a TAILQ_FIRST loop when releasing entries of the tailq, this is how it must be done. --- usr.sbin/smtpd/lka.c | 10 ++++++---- usr.sbin/smtpd/mfa.c | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 640e37560b2..9e8b19952a6 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.48 2009/05/20 14:29:44 gilles Exp $ */ +/* $OpenBSD: lka.c,v 1.49 2009/05/20 14:36:55 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -190,9 +190,10 @@ lka_dispatch_parent(int sig, short event, void *p) temp = env->sc_maps; env->sc_maps = env->sc_maps_reload; env->sc_maps_reload = temp; - + if (env->sc_rules_reload) { - TAILQ_FOREACH(r, env->sc_rules_reload, r_entry) { + while ((r = TAILQ_FIRST(env->sc_rules_reload))) { + TAILQ_REMOVE(env->sc_rules_reload, r, r_entry); free(r); } free(env->sc_rules_reload); @@ -200,7 +201,8 @@ lka_dispatch_parent(int sig, short event, void *p) } if (env->sc_maps_reload) { - TAILQ_FOREACH(m, env->sc_maps_reload, m_entry) { + while ((m = TAILQ_FIRST(env->sc_maps_reload))) { + TAILQ_REMOVE(env->sc_maps_reload, m, m_entry); free(m); } free(env->sc_maps_reload); diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c index b88d4d0f746..8f74d840fa7 100644 --- a/usr.sbin/smtpd/mfa.c +++ b/usr.sbin/smtpd/mfa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfa.c,v 1.27 2009/05/20 14:29:44 gilles Exp $ */ +/* $OpenBSD: mfa.c,v 1.28 2009/05/20 14:36:55 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -166,7 +166,8 @@ mfa_dispatch_parent(int sig, short event, void *p) env->sc_maps_reload = temp; if (env->sc_rules_reload) { - TAILQ_FOREACH(r, env->sc_rules_reload, r_entry) { + while ((r = TAILQ_FIRST(env->sc_rules_reload))) { + TAILQ_REMOVE(env->sc_rules_reload, r, r_entry); free(r); } free(env->sc_rules_reload); @@ -174,7 +175,8 @@ mfa_dispatch_parent(int sig, short event, void *p) } if (env->sc_maps_reload) { - TAILQ_FOREACH(m, env->sc_maps_reload, m_entry) { + while ((m = TAILQ_FIRST(env->sc_maps_reload))) { + TAILQ_REMOVE(env->sc_maps_reload, m, m_entry); free(m); } free(env->sc_maps_reload); -- cgit v1.2.3