diff options
-rw-r--r-- | usr.sbin/smtpd/config.c | 8 | ||||
-rw-r--r-- | usr.sbin/smtpd/parse.y | 13 |
2 files changed, 14 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/config.c b/usr.sbin/smtpd/config.c index 866276ba6e7..2f2142d6119 100644 --- a/usr.sbin/smtpd/config.c +++ b/usr.sbin/smtpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.8 2009/06/06 04:14:21 pyr Exp $ */ +/* $OpenBSD: config.c,v 1.9 2009/11/12 12:35:03 jacekm Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -61,6 +61,7 @@ purge_config(struct smtpd *env, u_int8_t what) struct cond *c; struct opt *o; struct ssl *s; + struct mapel *me; if (what & PURGE_LISTENERS) { while ((l = TAILQ_FIRST(env->sc_listeners)) != NULL) { @@ -73,6 +74,10 @@ purge_config(struct smtpd *env, u_int8_t what) if (what & PURGE_MAPS) { while ((m = TAILQ_FIRST(env->sc_maps)) != NULL) { TAILQ_REMOVE(env->sc_maps, m, m_entry); + while ((me = TAILQ_FIRST(&m->m_contents))) { + TAILQ_REMOVE(&m->m_contents, me, me_entry); + free(me); + } free(m); } free(env->sc_maps); @@ -91,6 +96,7 @@ purge_config(struct smtpd *env, u_int8_t what) } free(r); } + free(env->sc_rules); env->sc_rules = NULL; } if (what & PURGE_SSL) { diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 34daa852b4e..d845c8792e0 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.46 2009/11/05 12:24:13 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.47 2009/11/12 12:35:03 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -1359,25 +1359,25 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) bzero(conf, sizeof(*conf)); if ((conf->sc_maps = calloc(1, sizeof(*conf->sc_maps))) == NULL) { log_warn("cannot allocate memory"); - return 0; + return (-1); } if ((conf->sc_rules = calloc(1, sizeof(*conf->sc_rules))) == NULL) { log_warn("cannot allocate memory"); free(conf->sc_maps); - return 0; + return (-1); } if ((conf->sc_listeners = calloc(1, sizeof(*conf->sc_listeners))) == NULL) { log_warn("cannot allocate memory"); free(conf->sc_maps); free(conf->sc_rules); - return 0; + return (-1); } if ((conf->sc_ssl = calloc(1, sizeof(*conf->sc_ssl))) == NULL) { log_warn("cannot allocate memory"); free(conf->sc_maps); free(conf->sc_rules); free(conf->sc_listeners); - return 0; + return (-1); } if ((m = calloc(1, sizeof(*m))) == NULL) { log_warn("cannot allocate memory"); @@ -1385,7 +1385,7 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) free(conf->sc_rules); free(conf->sc_listeners); free(conf->sc_ssl); - return 0; + return (-1); } errors = 0; @@ -1406,6 +1406,7 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) if ((file = pushfile(filename, 0)) == NULL) { purge_config(conf, PURGE_EVERYTHING); + free(m); return (-1); } topfile = file; |