summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-08-19 17:34:37 +0000
committerJeremy Allison <jra@samba.org>2001-08-19 17:34:37 +0000
commit9326b82ffa255196ab68a23bf3f4ff14a7fd9bda (patch)
treea75da16f52d333b1ee8d2af28a25db5f34630774
parent66673eeeb42e1e82c5bd17c419c7a68ab89315fb (diff)
downloadsamba-9326b82ffa255196ab68a23bf3f4ff14a7fd9bda.tar.gz
samba-9326b82ffa255196ab68a23bf3f4ff14a7fd9bda.tar.bz2
samba-9326b82ffa255196ab68a23bf3f4ff14a7fd9bda.zip
Realloc fix.
Jeremy. (This used to be commit 9cabc3fd63d7780eb5d80eb7619fd7606d9da3b8)
-rw-r--r--source3/libsmb/namequery.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index c5c4d92c09..a0fb366f1b 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -335,6 +335,8 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
while (1)
{
struct timeval tval2;
+ struct in_addr *tmp_ip_list;
+
GetTimeOfDay(&tval2);
if (TvalDiff(&tval,&tval2) > retry_time) {
if (!retries)
@@ -398,9 +400,17 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
continue;
}
- ip_list = (struct in_addr *)Realloc( ip_list,
- sizeof( ip_list[0] )
- * ( (*count) + nmb2->answers->rdlength/6 ) );
+ tmp_ip_list = (struct in_addr *)Realloc( ip_list, sizeof( ip_list[0] )
+ * ( (*count) + nmb2->answers->rdlength/6 ) );
+
+ if (!tmp_ip_list) {
+ DEBUG(0,("name_query: Realloc failed.\n"));
+ if (ip_list)
+ free(ip_list);
+ }
+
+ ip_list = tmp_ip_list;
+
if (ip_list) {
DEBUG(2,("Got a positive name query response from %s ( ",
inet_ntoa(p2->ip)));