]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Cleanup coding in convert_ss2service().
authorJeremy Allison <jra@samba.org>
Wed, 26 Aug 2020 22:57:27 +0000 (15:57 -0700)
committerNoel Power <npower@samba.org>
Mon, 7 Sep 2020 13:23:43 +0000 (13:23 +0000)
Will make it easier to return a talloc'ed array.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/libsmb/namequery.c

index cc2fad30479c3bfe13defa3b2123bf01b15f4ace..607ad722aab47bb34fdc3313bd1f94da24771168 100644 (file)
@@ -1683,6 +1683,7 @@ static bool convert_ss2service(struct ip_service **return_iplist,
 {
        size_t i;
        size_t real_count = 0;
+       struct ip_service *iplist = NULL;
 
        if (orig_count == 0 || ss_list == NULL) {
                *count_out = 0;
@@ -1702,8 +1703,8 @@ static bool convert_ss2service(struct ip_service **return_iplist,
        }
 
        /* copy the ip address; port will be PORT_NONE */
-       *return_iplist = SMB_MALLOC_ARRAY(struct ip_service, real_count);
-       if (*return_iplist == NULL) {
+       iplist = SMB_MALLOC_ARRAY(struct ip_service, real_count);
+       if (iplist == NULL) {
                DBG_ERR("malloc failed for %zu enetries!\n", real_count);
                *count_out = 0;
                return false;
@@ -1714,11 +1715,12 @@ static bool convert_ss2service(struct ip_service **return_iplist,
                if (is_zero_addr(&ss_list[i])) {
                        continue;
                }
-               (*return_iplist)[real_count].ss   = ss_list[i];
-               (*return_iplist)[real_count].port = PORT_NONE;
+               iplist[real_count].ss   = ss_list[i];
+               iplist[real_count].port = PORT_NONE;
                real_count++;
        }
 
+       *return_iplist = iplist;
        *count_out = real_count;
        return true;
 }