s4:dsdb: Check return value of talloc_new()
authorJo Sutton <josutton@catalyst.net.nz>
Fri, 19 Jan 2024 00:33:09 +0000 (13:33 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 16 Feb 2024 02:41:36 +0000 (02:41 +0000)
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/util.c

index 0342da39a94a108b3d662004ae28fdce97810a3c..04dd055ef4d244811cfe2fd51e5cdb6b3b4e2a2b 100644 (file)
@@ -48,6 +48,9 @@ int dsdb_module_search_dn(struct ldb_module *module,
        struct ldb_result *res;
 
        tmp_ctx = talloc_new(mem_ctx);
+       if (tmp_ctx == NULL) {
+               return ldb_oom(ldb_module_get_ctx(module));
+       }
 
        res = talloc_zero(tmp_ctx, struct ldb_result);
        if (!res) {
@@ -128,6 +131,9 @@ int dsdb_module_search_tree(struct ldb_module *module,
        struct ldb_result *res;
 
        tmp_ctx = talloc_new(mem_ctx);
+       if (tmp_ctx == NULL) {
+               return ldb_oom(ldb_module_get_ctx(module));
+       }
 
        /* cross-partitions searches with a basedn break multi-domain support */
        SMB_ASSERT(basedn == NULL || (dsdb_flags & DSDB_SEARCH_SEARCH_ALL_PARTITIONS) == 0);
@@ -218,6 +224,9 @@ int dsdb_module_search(struct ldb_module *module,
        SMB_ASSERT(basedn == NULL || (dsdb_flags & DSDB_SEARCH_SEARCH_ALL_PARTITIONS) == 0);
 
        tmp_ctx = talloc_new(mem_ctx);
+       if (tmp_ctx == NULL) {
+               return ldb_oom(ldb_module_get_ctx(module));
+       }
 
        if (format) {
                va_start(ap, format);