]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:kdc: Don’t leak pub_keys.keys
authorJennifer Sutton <jennifersutton@catalyst.net.nz>
Thu, 9 Oct 2025 04:09:40 +0000 (17:09 +1300)
committerJennifer Sutton <jsutton@samba.org>
Wed, 22 Oct 2025 23:59:36 +0000 (23:59 +0000)
Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source4/kdc/db-glue.c

index 80915f2c99c56f8f5c2403e4a4e024e800b95ed2..6bdce0f3363fdc67318644c87183e6b72bdcb68c 100644 (file)
@@ -1880,14 +1880,16 @@ static krb5_error_code get_key_trust_public_keys(TALLOC_CTX *mem_ctx,
                                        goto pub_keys_oom;
                                }
                        } else {
-                               pub_keys.keys = realloc_p(pub_keys.keys,
-                                                       struct sdb_pub_key,
-                                                       pub_keys.len + 1);
-                               if (pub_keys.keys == NULL) {
+                               struct sdb_pub_key *keys = realloc_p(
+                                       pub_keys.keys,
+                                       struct sdb_pub_key,
+                                       pub_keys.len + 1);
+                               if (keys == NULL) {
                                        SAFE_FREE(pub_key.exponent.data);
                                        SAFE_FREE(pub_key.modulus.data);
                                        goto pub_keys_oom;
                                }
+                               pub_keys.keys = keys;
                        }
                        pub_keys.keys[pub_keys.len] = pub_key;
                        pub_keys.len++;