Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rtadvd plug memory leak. from kame
details: https://anonhg.NetBSD.org/src/rev/521d6c67d700
branches: trunk
changeset: 552159:521d6c67d700
user: itojun <itojun%NetBSD.org@localhost>
date: Sat Sep 20 13:04:07 2003 +0000
description:
plug memory leak. from kame
diffstat:
usr.sbin/rtadvd/if.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diffs (53 lines):
diff -r 27f0598dd838 -r 521d6c67d700 usr.sbin/rtadvd/if.c
--- a/usr.sbin/rtadvd/if.c Sat Sep 20 10:14:41 2003 +0000
+++ b/usr.sbin/rtadvd/if.c Sat Sep 20 13:04:07 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.14 2002/07/10 21:11:44 itojun Exp $ */
+/* $NetBSD: if.c,v 1.15 2003/09/20 13:04:07 itojun Exp $ */
/* $KAME: if.c,v 1.21 2002/05/21 14:26:55 itojun Exp $ */
/*
@@ -90,16 +90,14 @@
size_t len;
struct if_msghdr *ifm;
struct sockaddr *sa, *rti_info[RTAX_MAX];
- struct sockaddr_dl *sdl = NULL, *ret_sdl;
+ struct sockaddr_dl *sdl = NULL, *ret_sdl = NULL;
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
- return(NULL);
+ return (NULL);
if ((buf = malloc(len)) == NULL)
- return(NULL);
- if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
- free(buf);
- return(NULL);
- }
+ return (NULL);
+ if (sysctl(mib, 6, buf, &len, NULL, 0) < 0)
+ goto end;
lim = buf + len;
for (next = buf; next < lim; next += ifm->ifm_msglen) {
@@ -123,14 +121,17 @@
}
if (next == lim) {
/* search failed */
- free(buf);
- return(NULL);
+ goto end;
}
if ((ret_sdl = malloc(sdl->sdl_len)) == NULL)
- return(NULL);
+ goto end;
memcpy((caddr_t)ret_sdl, (caddr_t)sdl, sdl->sdl_len);
- return(ret_sdl);
+ return (ret_sdl);
+
+ end:
+ free(buf);
+ return (ret_sdl);
}
int
Home |
Main Index |
Thread Index |
Old Index