Skip to content

Commit

Permalink
(__nscd_getai): Avoid memory and file descriptor leaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Nov 22, 2004
1 parent 105b097 commit 8dd7199
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nscd/nscd_getai.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8dd7199

Please sign in to comment.