diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-11-22 18:41:05 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-11-22 18:41:05 +0000 |
commit | 8dd719970a2c282fa7b1fbf485f2744557abc676 (patch) | |
tree | 966da374b10a3f4dd5967cddcc00301acb2b2d7c /nscd/nscd_getai.c | |
parent | 105b0972ee99530260e70d42bd625618bf8d7d3b (diff) | |
download | glibc-8dd719970a2c282fa7b1fbf485f2744557abc676.tar.gz glibc-8dd719970a2c282fa7b1fbf485f2744557abc676.tar.xz glibc-8dd719970a2c282fa7b1fbf485f2744557abc676.zip |
(__nscd_getai): Avoid memory and file descriptor leaks.
Diffstat (limited to 'nscd/nscd_getai.c')
-rw-r--r-- | nscd/nscd_getai.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c index f0b2082baa..24b374b0dc 100644 --- a/nscd/nscd_getai.c +++ b/nscd/nscd_getai.c @@ -104,7 +104,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) if (resultbuf == NULL) { *h_errnop = NETDB_INTERNAL; - return -1; + goto out_close; } /* Set up the data structure, including pointers. */ @@ -140,7 +140,10 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) if (resultbuf->canon != NULL && resultbuf->canon[ai_resp->canonlen - 1] != '\0') /* We cannot use the database. */ - goto out_close; + { + free (resultbuf); + goto out_close; + } retval = 0; *result = resultbuf; @@ -173,6 +176,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) mapped = NO_MAPPING; } + *result = NULL; free (resultbuf); goto retry; |