s4: torture: Remove talloc_autofree_context() from locktest.
authorJeremy Allison <jra@samba.org>
Mon, 24 Apr 2017 23:18:16 +0000 (16:18 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 5 May 2017 13:52:14 +0000 (15:52 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source4/torture/locktest.c

index ac8d854a358d672a98a5268e945a0281f6520232..704755464ed016fe15119eef7dd35190ef7f6ecb 100644 (file)
@@ -580,18 +580,26 @@ int main(int argc, const char *argv[])
                POPT_COMMON_VERSION
                { NULL }
        };
+       TALLOC_CTX *mem_ctx = NULL;
+       int ret = -1;
 
        setlinebuf(stdout);
        seed = time(NULL);
 
+       mem_ctx = talloc_named_const(NULL, 0, "locktest_ctx");
+       if (mem_ctx == NULL) {
+               printf("Unable to allocate locktest_ctx\n");
+               exit(1);
+       }
+
        pc = poptGetContext("locktest", argc, argv, long_options,
                            POPT_CONTEXT_KEEP_FIRST);
 
        poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
 
        lp_ctx = cmdline_lp_ctx;
-       servers[0] = cli_credentials_init(talloc_autofree_context());
-       servers[1] = cli_credentials_init(talloc_autofree_context());
+       servers[0] = cli_credentials_init(mem_ctx);
+       servers[1] = cli_credentials_init(mem_ctx);
        cli_credentials_guess(servers[0], lp_ctx);
        cli_credentials_guess(servers[1], lp_ctx);
 
@@ -603,6 +611,7 @@ int main(int argc, const char *argv[])
                case 'U':
                        if (username_count == 2) {
                                usage(pc);
+                               talloc_free(mem_ctx);
                                exit(1);
                        }
                        cli_credentials_parse_string(servers[username_count], poptGetOptArg(pc), CRED_SPECIFIED);
@@ -642,7 +651,7 @@ int main(int argc, const char *argv[])
                servers[1] = servers[0];
        }
 
-       ev = s4_event_context_init(talloc_autofree_context());
+       ev = s4_event_context_init(mem_ctx);
 
        gensec_init();
 
@@ -650,6 +659,8 @@ int main(int argc, const char *argv[])
                 seed, lock_base, lock_range, min_length));
        srandom(seed);
 
-       return test_locks(ev, lp_ctx, NULL, share);
+       ret = test_locks(ev, lp_ctx, NULL, share);
+       talloc_free(mem_ctx);
+       return ret;
 }