summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2009-11-11 18:41:58 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2009-11-11 18:41:58 +0000
commitf638027d724c2a8c57ca7ee6b4c64ecadaf63c02 (patch)
tree478c69408aadadba797554ffbf04945bd6e06995
parent64f116f51b9954cf2a58e498a322cf60fd64ab74 (diff)
fix leaks in error cases found by parfait
ok blambert@ miod@ deraadt@
-rw-r--r--lib/libc/gen/getnetgrent.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 7c0b0b795ec..52614e4535c 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetgrent.c,v 1.21 2007/09/17 07:07:23 moritz Exp $ */
+/* $OpenBSD: getnetgrent.c,v 1.22 2009/11/11 18:41:57 jsg Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
@@ -89,8 +89,10 @@ _ng_sl_init(void)
sl->sl_cur = 0;
sl->sl_max = 20;
sl->sl_str = calloc(sl->sl_max, sizeof(char *));
- if (sl->sl_str == NULL)
+ if (sl->sl_str == NULL) {
+ free(sl);
return NULL;
+ }
return sl;
}
@@ -711,8 +713,10 @@ innetgr(const char *grp, const char *host, const char *user, const char *domain)
/* Too bad need the slow recursive way */
sl = _ng_sl_init();
- if (sl == NULL)
+ if (sl == NULL) {
+ free(grpdup);
return 0;
+ }
found = in_find(ypdom, sl, grpdup, host, user, domain);
_ng_sl_free(sl, 1);