summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-14 16:05:53 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-14 08:27:19 +0200
commit0f2a87b547be43b4764c48350fd03ff22e086806 (patch)
tree2ec771fe02fe53be2b62b42c949b2056f9dedd6f
parent1f7477349f1602b405df180d02f0bdef397ca589 (diff)
downloadsamba-0f2a87b547be43b4764c48350fd03ff22e086806.tar.gz
samba-0f2a87b547be43b4764c48350fd03ff22e086806.tar.bz2
samba-0f2a87b547be43b4764c48350fd03ff22e086806.zip
s4-dsdb: Improve memory handling in dsdb_schema_from_ldb_results() by adding a tmp_ctx
-rw-r--r--source4/dsdb/schema/schema_init.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index c0318cf9c4..1771b267cd 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -843,9 +843,16 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
struct loadparm_context *lp_ctx = NULL;
int ret;
- schema = dsdb_new_schema(mem_ctx);
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ if (!tmp_ctx) {
+ dsdb_oom(error_string, mem_ctx);
+ return ldb_operr(ldb);
+ }
+
+ schema = dsdb_new_schema(tmp_ctx);
if (!schema) {
dsdb_oom(error_string, mem_ctx);
+ talloc_free(tmp_ctx);
return ldb_operr(ldb);
}
@@ -856,6 +863,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
*error_string = talloc_asprintf(mem_ctx,
"schema_fsmo_init: no prefixMap attribute found");
DEBUG(0,(__location__ ": %s\n", *error_string));
+ talloc_free(tmp_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
info_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "schemaInfo");
@@ -866,6 +874,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
"schema_fsmo_init: dsdb_schema_info_blob_new() failed - %s",
win_errstr(status));
DEBUG(0,(__location__ ": %s\n", *error_string));
+ talloc_free(tmp_ctx);
return ldb_operr(ldb);
}
info_val = &info_val_default;
@@ -877,11 +886,13 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
"schema_fsmo_init: failed to load oid mappings: %s",
win_errstr(status));
DEBUG(0,(__location__ ": %s\n", *error_string));
+ talloc_free(tmp_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
ret = dsdb_load_ldb_results_into_schema(mem_ctx, ldb, schema, attrs_class_res, error_string);
if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
return ret;
}
@@ -907,6 +918,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
(schema->fsmo.we_are_master?"yes":"no"),
(schema->fsmo.update_allowed?"yes":"no")));
- *schema_out = schema;
+ *schema_out = talloc_steal(mem_ctx, schema);
+ talloc_free(tmp_ctx);
return LDB_SUCCESS;
}