s4:dsdb/partition_init: don't leak a talloc_new() in case we have no data yet
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Oct 2009 13:11:08 +0000 (15:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 24 Oct 2009 09:59:15 +0000 (11:59 +0200)
metze

source4/dsdb/samdb/ldb_modules/partition_init.c

index cc778d6a710007d7a21ab2b92e6f633fac07d3a1..28eab9b2eece561324819ab05c4d5623cff8d44b 100644 (file)
@@ -353,22 +353,25 @@ static int add_partition_to_data(struct ldb_context *ldb, struct partition_priva
 
 int partition_reload_if_required(struct ldb_module *module, 
                                 struct partition_private_data *data)
-       
 {
        uint64_t seq;
        int ret, i;
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct ldb_message *msg;
        struct ldb_message_element *partition_attributes;
-       TALLOC_CTX *mem_ctx = talloc_new(data);
+       TALLOC_CTX *mem_ctx;
+
        if (!data) {
                /* Not initilised yet */
                return LDB_SUCCESS;
        }
+
+       mem_ctx = talloc_new(data);
        if (!mem_ctx) {
                ldb_oom(ldb);
                return LDB_ERR_OPERATIONS_ERROR;
        }
+
        ret = partition_primary_sequence_number(module, mem_ctx, LDB_SEQ_HIGHEST_SEQ, &seq);
        if (ret != LDB_SUCCESS) {
                talloc_free(mem_ctx);