]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: Fix leak on reallocation failure in pull_composite()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 20 Sep 2023 03:03:28 +0000 (15:03 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 25 Oct 2023 22:23:37 +0000 (22:23 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/security/conditional_ace.c

index 6fb0cd3a38bb9feaef5d94f9e6b64a4a8ea2dcd4..7f4766ed135962c8e345ebc27398ed693b2b1b8b 100644 (file)
@@ -381,15 +381,18 @@ static ssize_t pull_composite(TALLOC_CTX *mem_ctx,
                        return -1;
                }
                if (j == alloc_length) {
+                       struct ace_condition_token *new_tokens = NULL;
+
                        alloc_length += 5;
-                       tokens = talloc_realloc(mem_ctx,
-                                               tokens,
-                                               struct ace_condition_token,
-                                               alloc_length);
+                       new_tokens = talloc_realloc(mem_ctx,
+                                                   tokens,
+                                                   struct ace_condition_token,
+                                                   alloc_length);
 
-                       if (tokens == NULL) {
-                               return -1;
+                       if (new_tokens == NULL) {
+                               goto error;
                        }
+                       tokens = new_tokens;
                }
        }
        tok->n_members = j;