From cc9771d3daa84994ceec427127a71a3cf0a34b9a Mon Sep 17 00:00:00 2001 From: "scudette@gmail.com" Date: Fri, 2 Jan 2009 22:40:32 +1100 Subject: Memory leak fixed due to accumulation of open reg keys. --- source4/lib/registry/tools/regtree.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index cca009a0e2..948ed49312 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -55,13 +55,16 @@ static void print_tree(int level, struct registry_key *p, &keyname, NULL, NULL)); i++) { - SMB_ASSERT(strlen(keyname) > 0); + + SMB_ASSERT(strlen(keyname) > 0); if (!W_ERROR_IS_OK(reg_open_key(mem_ctx, p, keyname, &subkey))) - continue; + continue; + print_tree(level+1, subkey, (fullpath && strlen(name))? - talloc_asprintf(mem_ctx, "%s\\%s", - name, keyname): - keyname, fullpath, novals); + talloc_asprintf(mem_ctx, "%s\\%s", + name, keyname): + keyname, fullpath, novals); + talloc_free(subkey); } talloc_free(mem_ctx); -- cgit From 793f1cdbd918f2245255176572027763664d9d0b Mon Sep 17 00:00:00 2001 From: "scudette@gmail.com" Date: Fri, 2 Jan 2009 22:41:04 +1100 Subject: Changed code to use proper talloc context instead of NULL to control memory leak. --- source4/lib/registry/tools/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index c9f1248bf8..d997cb0fde 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -51,7 +51,7 @@ struct registry_key *reg_common_open_file(const char *path, struct registry_context *h = NULL; WERROR error; - error = reg_open_hive(NULL, path, NULL, creds, ev_ctx, lp_ctx, &hive_root); + error = reg_open_hive(ev_ctx, path, NULL, creds, ev_ctx, lp_ctx, &hive_root); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s': %s \n", -- cgit