summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-09-21 04:06:02 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2003-09-21 04:06:02 +0000
commit96dd78902e2a70c2a18e51c6407fe5101aa4f771 (patch)
tree39a6e5e0ad5adae0b6990edaadd9298489d5a678 /usr.sbin
parent023bd3f8cfa6e289ad653beedceb21dcbcd02bb3 (diff)
plug memory leak. from kame. fgsch ok
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rtadvd/if.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c
index 27247e7bb27..f5f29dee94a 100644
--- a/usr.sbin/rtadvd/if.c
+++ b/usr.sbin/rtadvd/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.14 2002/06/10 19:57:35 espie Exp $ */
+/* $OpenBSD: if.c,v 1.15 2003/09/21 04:06:01 itojun Exp $ */
/* $KAME: if.c,v 1.17 2001/01/21 15:27:30 itojun Exp $ */
/*
@@ -90,16 +90,14 @@ if_nametosdl(char *name)
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_nametosdl(char *name)
}
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