diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-03-03 17:08:46 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-03-03 17:08:46 +0000 |
commit | 62d49f53f3c46598d7ad6b324206cc29607cf71f (patch) | |
tree | 4bd8f60af8c2bd26b0c287b32a4262e98f6ed853 /usr.sbin/bgpd/kroute.c | |
parent | 40a6f2816fac141cc3c48b2f413058c574d830dd (diff) |
plug a couple of little memory leaks in error paths that we hopefully never
reach - except for one missing free which was not in an error path. oups. at
least in a function that is only called once ever in bgpd's lifetime.
From: Patrick Latifi <pat at eyeo dot org>, thanks!
Diffstat (limited to 'usr.sbin/bgpd/kroute.c')
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 32b90ffc837..813c1acf2b2 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.87 2004/02/29 11:14:19 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.88 2004/03/03 17:08:45 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -973,6 +973,7 @@ fetchtable(void) } if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) { log_warn("sysctl"); + free(buf); return (-1); } @@ -990,6 +991,7 @@ fetchtable(void) if ((kr = calloc(1, sizeof(struct kroute_node))) == NULL) { log_warn("fetchtable"); + free(buf); return (-1); } @@ -1012,6 +1014,7 @@ fetchtable(void) prefixlen_classful(kr->r.prefix.s_addr); break; default: + free(kr); continue; /* not reached */ } @@ -1063,6 +1066,7 @@ fetchifs(int ifindex) } if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) { log_warn("sysctl"); + free(buf); return (-1); } @@ -1077,6 +1081,7 @@ fetchifs(int ifindex) if ((kif = calloc(1, sizeof(struct kif_node))) == NULL) { log_warn("fetchifs"); + free(buf); return (-1); } @@ -1098,6 +1103,7 @@ fetchifs(int ifindex) kif_insert(kif); } + free(buf); return (0); } |