From 4fc2b5c40e63579c2fe4e95bdbaa31108f2b3475 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 20 Sep 2010 04:12:42 +0200 Subject: s3:services_db: use temp talloc ctx in svcctl_get_secdesc() --- source3/services/services_db.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source3/services') diff --git a/source3/services/services_db.c b/source3/services/services_db.c index baac9d90d5..1ebaa77aa0 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -521,14 +521,17 @@ struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *nam char *path= NULL; WERROR wresult; NTSTATUS status; + TALLOC_CTX *mem_ctx = talloc_stackframe(); /* now add the security descriptor */ - if (asprintf(&path, "%s\\%s\\%s", KEY_SERVICES, name, "Security") < 0) { - return NULL; + path = talloc_asprintf(mem_ctx, "%s\\%s\\%s", KEY_SERVICES, name, + "Security"); + if (path == NULL) { + goto done; } - wresult = regkey_open_internal( NULL, &key, path, token, - REG_KEY_ALL ); + + wresult = regkey_open_internal(mem_ctx, &key, path, token, REG_KEY_ALL); if ( !W_ERROR_IS_OK(wresult) ) { DEBUG(0,("svcctl_get_secdesc: key lookup failed! [%s] (%s)\n", path, win_errstr(wresult))); @@ -565,8 +568,7 @@ fallback_to_default_sd: ret_sd = construct_service_sd(ctx); done: - SAFE_FREE(path); - TALLOC_FREE(key); + talloc_free(mem_ctx); return ret_sd; } -- cgit