summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-09-08 05:18:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:35 -0500
commit2400758fbef9f3a5a8b7138053ca75586af80dce (patch)
treec9a0c11f817c45df8e27408106594a685a8c94f6
parent923f14ff37cc1ea70631cb9037685246d941cfae (diff)
downloadsamba-2400758fbef9f3a5a8b7138053ca75586af80dce.tar.gz
samba-2400758fbef9f3a5a8b7138053ca75586af80dce.tar.xz
samba-2400758fbef9f3a5a8b7138053ca75586af80dce.zip
r25022: Fix coverity #395. Resource leak on error.
Jeremy. (This used to be commit 6a237600b825f4df2241277bdd80e98669f69685)
-rw-r--r--source3/nsswitch/wins.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c
index afc1639f630..8e4d75e545a 100644
--- a/source3/nsswitch/wins.c
+++ b/source3/nsswitch/wins.c
@@ -315,8 +315,10 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
namelen = strlen(name) + 1;
- if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL)
+ if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) {
+ free(ip_list);
return NSS_STATUS_TRYAGAIN;
+ }
memcpy(he->h_name, name, namelen);
@@ -325,24 +327,29 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
if ((i = (unsigned long)(buffer) % sizeof(char*)) != 0)
i = sizeof(char*) - i;
- if (get_static(&buffer, &buflen, i) == NULL)
+ if (get_static(&buffer, &buflen, i) == NULL) {
+ free(ip_list);
return NSS_STATUS_TRYAGAIN;
+ }
if ((he->h_addr_list = (char **)get_static(
- &buffer, &buflen, (count + 1) * sizeof(char *))) == NULL)
+ &buffer, &buflen, (count + 1) * sizeof(char *))) == NULL) {
+ free(ip_list);
return NSS_STATUS_TRYAGAIN;
+ }
for (i = 0; i < count; i++) {
if ((he->h_addr_list[i] = get_static(&buffer, &buflen,
- INADDRSZ)) == NULL)
+ INADDRSZ)) == NULL) {
+ free(ip_list);
return NSS_STATUS_TRYAGAIN;
+ }
memcpy(he->h_addr_list[i], &ip_list[i], INADDRSZ);
}
he->h_addr_list[count] = NULL;
- if (ip_list)
- free(ip_list);
+ free(ip_list);
/* Set h_addr_type and h_length */