]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Realloc fix.
authorJeremy Allison <jra@samba.org>
Sun, 19 Aug 2001 17:34:37 +0000 (17:34 +0000)
committerJeremy Allison <jra@samba.org>
Sun, 19 Aug 2001 17:34:37 +0000 (17:34 +0000)
Jeremy.
(This used to be commit 9cabc3fd63d7780eb5d80eb7619fd7606d9da3b8)

source3/libsmb/namequery.c

index c5c4d92c092d70d0a9803908778dec5168605591..a0fb366f1b518a555cb95321de6567f02a6857ac 100644 (file)
@@ -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)));