s4: torture: Use a named TALLOC_CTX in masktest instead of talloc_autofree_context().
[gd/samba-autobuild/.git] / source4 / torture / masktest.c
index 2097de4e5febe53b5e0f5e7ccf2ae993520abe06..7f1be866d0705f2734de41686e0baf82da5b53dc 100644 (file)
@@ -268,7 +268,6 @@ static void test_mask(int argc, char *argv[],
 
  finished:
        smbcli_rmdir(cli->tree, "\\masktest");
-       talloc_free(mem_ctx);
 }
 
 
@@ -300,7 +299,7 @@ int main(int argc, const char *argv[])
        poptContext pc;
        int argc_new, i;
        char **argv_new;
-       TALLOC_CTX *mem_ctx;
+       TALLOC_CTX *mem_ctx = NULL;
        enum {OPT_UNCLIST=1000};
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -322,6 +321,11 @@ int main(int argc, const char *argv[])
        setlinebuf(stdout);
        seed = time(NULL);
 
+       mem_ctx = talloc_named_const(NULL, 0, "masktest_ctx");
+       if (mem_ctx == NULL) {
+               exit(1);
+       }
+
        pc = poptGetContext("locktest", argc, argv, long_options,
                            POPT_CONTEXT_KEEP_FIRST);
 
@@ -346,6 +350,7 @@ int main(int argc, const char *argv[])
 
        if (!(argc_new >= 2)) {
                usage(pc);
+               talloc_free(mem_ctx);
                exit(1);
        }
 
@@ -357,8 +362,6 @@ int main(int argc, const char *argv[])
 
        lp_ctx = cmdline_lp_ctx;
 
-       mem_ctx = talloc_autofree_context();
-
        ev = s4_event_context_init(mem_ctx);
 
        gensec_init();
@@ -372,6 +375,7 @@ int main(int argc, const char *argv[])
                          lpcfg_gensec_settings(mem_ctx, lp_ctx));
        if (!cli) {
                DEBUG(0,("Failed to connect to %s\n", share));
+               talloc_free(mem_ctx);
                exit(1);
        }
 
@@ -381,5 +385,6 @@ int main(int argc, const char *argv[])
 
        test_mask(argc_new-1, argv_new+1, mem_ctx, cli);
 
+       talloc_free(mem_ctx);
        return(0);
 }