summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-01-09 05:36:02 -0600
committerStefan Metzmacher <metze@samba.org>2008-01-08 23:42:02 -0600
commit4d58fc88cbba394faa83b493ec79344935a497f8 (patch)
tree4e0920c3a01becca56cf3f0c2d5a6599f77b1759 /source4/dsdb/schema
parente3f0e64ef083cbad37c0e967e5ab3de6a840b7f9 (diff)
downloadsamba-4d58fc88cbba394faa83b493ec79344935a497f8.tar.gz
samba-4d58fc88cbba394faa83b493ec79344935a497f8.tar.bz2
samba-4d58fc88cbba394faa83b493ec79344935a497f8.zip
r26697: Leak less memory into the ldb context.
(Trying to chase down memory leaks in provision) Andrew Bartlett (This used to be commit a0cf47c3359ca5dfab90c1a5831a73b89ff9f027)
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_init.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 3dd81fb822..6a7463951e 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -85,24 +85,30 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema *schema,
struct prefixMapBlob pfm;
char *schema_info;
- ndr_err = ndr_pull_struct_blob(prefixMap, schema, lp_iconv_convenience(global_loadparm), &pfm,
+ TALLOC_CTX *mem_ctx = talloc_new(schema);
+ W_ERROR_HAVE_NO_MEMORY(mem_ctx);
+
+ ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm,
(ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
+ talloc_free(mem_ctx);
return ntstatus_to_werror(nt_status);
}
if (pfm.version != PREFIX_MAP_VERSION_DSDB) {
+ talloc_free(mem_ctx);
return WERR_FOOBAR;
}
if (schemaInfo->length != 21 && schemaInfo->data[0] == 0xFF) {
+ talloc_free(mem_ctx);
return WERR_FOOBAR;
}
/* append the schema info as last element */
pfm.ctr.dsdb.num_mappings++;
- pfm.ctr.dsdb.mappings = talloc_realloc(schema, pfm.ctr.dsdb.mappings,
+ pfm.ctr.dsdb.mappings = talloc_realloc(mem_ctx, pfm.ctr.dsdb.mappings,
struct drsuapi_DsReplicaOIDMapping,
pfm.ctr.dsdb.num_mappings);
W_ERROR_HAVE_NO_MEMORY(pfm.ctr.dsdb.mappings);
@@ -116,7 +122,8 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema *schema,
/* call the drsuapi version */
status = dsdb_load_oid_mappings_drsuapi(schema, &pfm.ctr.dsdb);
- talloc_free(pfm.ctr.dsdb.mappings);
+ talloc_free(mem_ctx);
+
W_ERROR_NOT_OK_RETURN(status);
return WERR_OK;
@@ -1164,6 +1171,8 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf
if (!msg) {
goto nomem;
}
+ talloc_steal(mem_ctx, msg);
+ talloc_free(ldif);
prefix_val = ldb_msg_find_ldb_val(msg, "prefixMap");
if (!prefix_val) {
@@ -1200,6 +1209,9 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf
goto nomem;
}
+ talloc_steal(mem_ctx, msg);
+ talloc_free(ldif);
+
is_sa = ldb_msg_check_string_attribute(msg, "objectClass", "attributeSchema");
is_sc = ldb_msg_check_string_attribute(msg, "objectClass", "classSchema");