summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2012-04-02 18:56:16 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2012-04-02 18:56:16 +0000
commit7d5ba8866bd9b6f0367d77df44f4e266b4f925fa (patch)
tree861ebc3f48ac95548fc932802c6c3d1419ca7165 /usr.sbin
parent1996c0ab618ce5149a795d9b0d1d62f29ed1f67c (diff)
Fix memory leak in error path, originally based on a diff from jsg@.
OK deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/sasyncd/monitor.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/usr.sbin/sasyncd/monitor.c b/usr.sbin/sasyncd/monitor.c
index 411af05af39..4e4b18a4f7e 100644
--- a/usr.sbin/sasyncd/monitor.c
+++ b/usr.sbin/sasyncd/monitor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor.c,v 1.14 2010/06/29 18:10:04 kjell Exp $ */
+/* $OpenBSD: monitor.c,v 1.15 2012/04/02 18:56:15 millert Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -401,28 +401,24 @@ m_priv_pfkey_snap(int s)
v = (u_int32_t)sadb_buflen;
if (m_write(s, &v, sizeof v) == -1) {
log_err("m_priv_pfkey_snap: write");
- return;
- }
- if (sadb_buflen) {
- if (m_write(s, sadb_buf, sadb_buflen) == -1)
- log_err("m_priv_pfkey_snap: write");
- memset(sadb_buf, 0, sadb_buflen);
- free(sadb_buf);
+ goto cleanup;
}
+ if (m_write(s, sadb_buf, sadb_buflen) == -1)
+ log_err("m_priv_pfkey_snap: write");
/* Return SPD data */
v = (u_int32_t)spd_buflen;
if (m_write(s, &v, sizeof v) == -1) {
log_err("m_priv_pfkey_snap: write");
- return;
- }
- if (spd_buflen) {
- if (m_write(s, spd_buf, spd_buflen) == -1)
- log_err("m_priv_pfkey_snap: write");
- memset(spd_buf, 0, spd_buflen);
- free(spd_buf);
+ goto cleanup;
}
- return;
+ if (m_write(s, spd_buf, spd_buflen) == -1)
+ log_err("m_priv_pfkey_snap: write");
+ cleanup:
+ memset(sadb_buf, 0, sadb_buflen);
+ free(sadb_buf);
+ memset(spd_buf, 0, spd_buflen);
+ free(spd_buf);
}
static int