Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libipsec Avoid memory leak. Pointed out by Patrick Latif...
details: https://anonhg.NetBSD.org/src/rev/824c2fac51c6
branches: trunk
changeset: 543827:824c2fac51c6
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 04 18:30:58 2003 +0000
description:
Avoid memory leak. Pointed out by Patrick Latifi <patrickl at secureops dot com>
diffstat:
lib/libipsec/pfkey.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (31 lines):
diff -r 48c6d78980ae -r 824c2fac51c6 lib/libipsec/pfkey.c
--- a/lib/libipsec/pfkey.c Tue Mar 04 18:09:48 2003 +0000
+++ b/lib/libipsec/pfkey.c Tue Mar 04 18:30:58 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pfkey.c,v 1.13 2002/05/14 11:24:21 itojun Exp $ */
+/* $NetBSD: pfkey.c,v 1.14 2003/03/04 18:30:58 christos Exp $ */
/* $KAME: pfkey.c,v 1.41 2002/05/14 10:59:09 itojun Exp $ */
/*
@@ -700,14 +700,17 @@
{
pid_t pid = getpid();
struct sadb_msg *newmsg;
- int error = -1;
+ int error;
/* receive message */
- do {
+ for (;;) {
if ((newmsg = pfkey_recv(so)) == NULL)
return -1;
- } while (newmsg->sadb_msg_type != SADB_REGISTER
- || newmsg->sadb_msg_pid != pid);
+ if (newmsg->sadb_msg_type == SADB_REGISTER
+ && newmsg->sadb_msg_pid == pid)
+ break;
+ free(newmsg);
+ }
/* check and fix */
newmsg->sadb_msg_len = PFKEY_UNUNIT64(newmsg->sadb_msg_len);
Home |
Main Index |
Thread Index |
Old Index