dsdb: linked attrs: check a talloc_new()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 9 Jan 2019 04:55:38 +0000 (17:55 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 13 Feb 2019 03:15:14 +0000 (04:15 +0100)
Also we can defer it past a thing that doesn't need or check for it.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/linked_attributes.c

index 2568d4d17900b5ae0b3de20cab61e3b73b5293d3..816968584b529f44376d67118d4f6f1ddf5ae35f 100644 (file)
@@ -695,7 +695,7 @@ static int linked_attributes_fix_links(struct ldb_module *module,
                                       struct ldb_request *parent)
 {
        unsigned int i, j;
-       TALLOC_CTX *tmp_ctx = talloc_new(module);
+       TALLOC_CTX *tmp_ctx = NULL;
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        const struct dsdb_attribute *target;
        const char *attrs[2];
@@ -707,6 +707,11 @@ static int linked_attributes_fix_links(struct ldb_module *module,
                return LDB_SUCCESS;
        }
 
+       tmp_ctx = talloc_new(module);
+       if (tmp_ctx == NULL) {
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+
        attrs[0] = target->lDAPDisplayName;
        attrs[1] = NULL;