]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbind: Simplify winbindd_getusersids_recv()
authorVolker Lendecke <vl@samba.org>
Wed, 6 Oct 2021 08:10:21 +0000 (10:10 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 8 Oct 2021 19:28:31 +0000 (19:28 +0000)
Use talloc_asprintf_addbuf(), fix an realloc error path memleak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_getusersids.c

index 3924d4933e5a9130e34114ea1da0555ef2d90070..1f2546a7ba196c70d438ff52401fce5d9fd48ed1 100644 (file)
@@ -101,18 +101,16 @@ NTSTATUS winbindd_getusersids_recv(struct tevent_req *req,
        }
 
        result = talloc_strdup(response, "");
-       if (result == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
 
        for (i=0; i<state->num_sids; i++) {
-               result = talloc_asprintf_append_buffer(
-                       result,
+               talloc_asprintf_addbuf(
+                       &result,
                        "%s\n",
                        dom_sid_str_buf(&state->sids[i], &sidbuf));
-               if (result == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+       }
+
+       if (result == NULL) {
+               return NT_STATUS_NO_MEMORY;
        }
 
        response->data.num_entries = state->num_sids;