]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbindd: Simplify winbindd_getuserdomgroups_recv()
authorVolker Lendecke <vl@samba.org>
Tue, 24 Feb 2026 09:16:41 +0000 (10:16 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 25 Feb 2026 12:33:39 +0000 (12:33 +0000)
Only check for NULL once with talloc_asprintf_addbuf()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
source3/winbindd/winbindd_getuserdomgroups.c

index 3187be6d5864b30c54f3418840d173a346210263..72e7ec969103000fc674d41465b1b1048016ca69 100644 (file)
@@ -99,21 +99,18 @@ NTSTATUS winbindd_getuserdomgroups_recv(struct tevent_req *req,
        }
 
        sidlist = talloc_strdup(response, "");
-       if (sidlist == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
        D_NOTICE("Winbind external command GETUSERDOMGROUPS end.\n"
                 "Received %"PRIu32" entries.\n",
                 state->num_sids);
        for (i=0; i<state->num_sids; i++) {
                struct dom_sid_buf tmp;
                const char *str = dom_sid_str_buf(&state->sids[i], &tmp);
-               sidlist = talloc_asprintf_append_buffer(sidlist, "%s\n", str);
-               if (sidlist == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(&sidlist, "%s\n", str);
                D_NOTICE("%" PRIu32 ": %s\n", i, str);
        }
+       if (sidlist == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
        response->extra_data.data = sidlist;
        response->length += talloc_get_size(sidlist);
        response->data.num_entries = state->num_sids;