diff options
author | Andrew Bartlett <abartlet@samba.org> | 2016-08-04 15:20:27 +1200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2016-08-11 00:49:14 +0200 |
commit | c533b60ceb761b609e78dfe270930cb99fdac848 (patch) | |
tree | e586270dfe8ef352a5fa4860074509727ccfa65a /source4/dsdb/repl | |
parent | 0a1627de6d7c70f2462a4d4db717ea50c8aefc2f (diff) | |
download | samba-c533b60ceb761b609e78dfe270930cb99fdac848.tar.gz |
s4:dsdb/repl: Improve memory handling in replicated schema code
This attempts to make it clear what memory is short term and what memory is long term
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12115
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/dsdb/repl')
-rw-r--r-- | source4/dsdb/repl/replicated_objects.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c index fb8083d4bb4..17b68a42d2a 100644 --- a/source4/dsdb/repl/replicated_objects.c +++ b/source4/dsdb/repl/replicated_objects.c @@ -103,7 +103,6 @@ static WERROR dsdb_repl_merge_working_schema(struct ldb_context *ldb, } WERROR dsdb_repl_resolve_working_schema(struct ldb_context *ldb, - TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap *pfm_remote, uint32_t cycle_before_switching, struct dsdb_schema *initial_schema, @@ -129,10 +128,11 @@ WERROR dsdb_repl_resolve_working_schema(struct ldb_context *ldb, DRSUAPI_ATTID_systemPossSuperiors, DRSUAPI_ATTID_INVALID }; + TALLOC_CTX *frame = talloc_stackframe(); /* create a list of objects yet to be converted */ for (cur = first_object; cur; cur = cur->next_object) { - schema_list_item = talloc(mem_ctx, struct schema_list); + schema_list_item = talloc(frame, struct schema_list); if (schema_list_item == NULL) { return WERR_NOMEM; } @@ -164,6 +164,7 @@ WERROR dsdb_repl_resolve_working_schema(struct ldb_context *ldb, working_schema, resulting_schema); if (!W_ERROR_IS_OK(werr)) { + talloc_free(frame); return werr; } } @@ -242,6 +243,7 @@ WERROR dsdb_repl_resolve_working_schema(struct ldb_context *ldb, "all %d remaining of %d objects " "failed to convert\n", failed_obj_count, object_count)); + talloc_free(frame); return WERR_INTERNAL_ERROR; } @@ -257,12 +259,14 @@ WERROR dsdb_repl_resolve_working_schema(struct ldb_context *ldb, ret = dsdb_setup_sorted_accessors(ldb, working_schema); if (LDB_SUCCESS != ret) { DEBUG(0,("Failed to create schema-cache indexes!\n")); + talloc_free(frame); return WERR_INTERNAL_ERROR; } } pass_no++; } + talloc_free(frame); return WERR_OK; } @@ -298,14 +302,15 @@ WERROR dsdb_repl_make_working_schema(struct ldb_context *ldb, /* we are going to need remote prefixMap for decoding */ werr = dsdb_schema_pfm_from_drsuapi_pfm(mapping_ctr, true, - mem_ctx, &pfm_remote, NULL); + working_schema, &pfm_remote, NULL); if (!W_ERROR_IS_OK(werr)) { DEBUG(0,(__location__ ": Failed to decode remote prefixMap: %s", win_errstr(werr))); + talloc_free(working_schema); return werr; } - werr = dsdb_repl_resolve_working_schema(ldb, mem_ctx, + werr = dsdb_repl_resolve_working_schema(ldb, pfm_remote, 0, /* cycle_before_switching */ working_schema, @@ -315,6 +320,7 @@ WERROR dsdb_repl_make_working_schema(struct ldb_context *ldb, if (!W_ERROR_IS_OK(werr)) { DEBUG(0, ("%s: dsdb_repl_resolve_working_schema() failed: %s", __location__, win_errstr(werr))); + talloc_free(working_schema); return werr; } |