Don't leak: Use a temporary context for the admin token and free it.
authorMichael Adam <obnox@samba.org>
Thu, 3 Jan 2008 00:26:31 +0000 (01:26 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 3 Jan 2008 00:29:43 +0000 (01:29 +0100)
Michael

source/libnet/libnet_conf.c

index ca5b0c408fb9addc1258adc17ea4fa9783da443c..995fc1b303e9ecd682a793ad1efc514054b4cbb4 100644 (file)
@@ -64,6 +64,7 @@ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
 {
        WERROR werr = WERR_OK;
        NT_USER_TOKEN *token;
+       TALLOC_CTX *tmp_ctx = NULL;
 
        if (path == NULL) {
                DEBUG(1, ("Error: NULL path string given\n"));
@@ -71,7 +72,13 @@ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       token = registry_create_admin_token(mem_ctx);
+       tmp_ctx = talloc_new(mem_ctx);
+       if (tmp_ctx == NULL) {
+               werr = WERR_NOMEM;
+               goto done;
+       }
+
+       token = registry_create_admin_token(tmp_ctx);
        if (token == NULL) {
                DEBUG(1, ("Error creating admin token\n"));
                /* what is the appropriate error code here? */
@@ -87,6 +94,7 @@ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
        }
 
 done:
+       TALLOC_FREE(tmp_ctx);
        return werr;
 }