Skip to content

Commit

Permalink
s4: free popt context in torture
Browse files Browse the repository at this point in the history
If done with popt context it should be free'd.

Signed-off-by: Swen Schillig <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Ralph Böhme <[email protected]>
  • Loading branch information
sswen authored and abartlet committed Aug 22, 2019
1 parent 355c9f5 commit 42123c1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source4/torture/gentest.c
Original file line number Diff line number Diff line change
Expand Up @@ -3398,13 +3398,15 @@ int main(int argc, const char *argv[])
const char *share = argv[1+i];
if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
printf("Invalid share name '%s'\n", share);
poptFreeContext(pc);
talloc_free(mem_ctx);
return -1;
}
}

if (username_count == 0) {
usage(pc);
poptFreeContext(pc);
talloc_free(mem_ctx);
return -1;
}
Expand All @@ -3426,6 +3428,7 @@ int main(int argc, const char *argv[])
printf("gentest failed\n");
}

poptFreeContext(pc);
talloc_free(mem_ctx);
return ret?0:-1;
}
2 changes: 2 additions & 0 deletions source4/torture/locktest.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ int main(int argc, const char *argv[])

if (username_count == 0) {
usage(pc);
poptFreeContext(pc);
return -1;
}
if (username_count == 1) {
Expand All @@ -660,6 +661,7 @@ int main(int argc, const char *argv[])
srandom(seed);

ret = test_locks(ev, lp_ctx, NULL, share);
poptFreeContext(pc);
talloc_free(mem_ctx);
return ret;
}
Expand Down
1 change: 1 addition & 0 deletions source4/torture/masktest.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ int main(int argc, const char *argv[])

test_mask(argc_new-1, argv_new+1, mem_ctx, cli);

poptFreeContext(pc);
talloc_free(mem_ctx);
return(0);
}
8 changes: 8 additions & 0 deletions source4/torture/smbtorture.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ int main(int argc, const char *argv[])

if (list_testsuites) {
print_testsuite_list();
poptFreeContext(pc);
talloc_free(mem_ctx);
popt_free_cmdline_credentials();
return 0;
Expand All @@ -610,6 +611,7 @@ int main(int argc, const char *argv[])
print_test_list(torture_root, NULL, argv_new[i]);
}
}
poptFreeContext(pc);
talloc_free(mem_ctx);
popt_free_cmdline_credentials();
return 0;
Expand Down Expand Up @@ -638,6 +640,7 @@ int main(int argc, const char *argv[])
if (basedir != NULL) {
if (basedir[0] != '/') {
fprintf(stderr, "Please specify an absolute path to --basedir\n");
poptFreeContext(pc);
talloc_free(mem_ctx);
return 1;
}
Expand All @@ -646,19 +649,22 @@ int main(int argc, const char *argv[])
char *pwd = talloc_size(torture, PATH_MAX);
if (!getcwd(pwd, PATH_MAX)) {
fprintf(stderr, "Unable to determine current working directory\n");
poptFreeContext(pc);
talloc_free(mem_ctx);
return 1;
}
outputdir = talloc_asprintf(torture, "%s/smbtortureXXXXXX", pwd);
}
if (!outputdir) {
fprintf(stderr, "Could not allocate per-run output dir\n");
poptFreeContext(pc);
talloc_free(mem_ctx);
return 1;
}
torture->outputdir = mkdtemp(outputdir);
if (!torture->outputdir) {
perror("Failed to make temp output dir");
poptFreeContext(pc);
talloc_free(mem_ctx);
return 1;
}
Expand Down Expand Up @@ -700,10 +706,12 @@ int main(int argc, const char *argv[])
torture_deltree_outputdir(torture);

if (torture->results->returncode && correct) {
poptFreeContext(pc);
talloc_free(mem_ctx);
popt_free_cmdline_credentials();
return(0);
} else {
poptFreeContext(pc);
talloc_free(mem_ctx);
return(1);
}
Expand Down

0 comments on commit 42123c1

Please sign in to comment.