From: Swen Schillig Date: Mon, 19 Aug 2019 11:09:25 +0000 (+0200) Subject: lib: free popt context in texpect X-Git-Tag: tevent-0.10.1~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7383889282d3b92a9c2eaded85a5ba20e828134;p=thirdparty%2Fsamba.git lib: free popt context in texpect If done with popt context it should be free'd. Signed-off-by: Swen Schillig Reviewed-by: Andrew Bartlett Reviewed-by: Ralph Böhme Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Thu Aug 22 01:41:37 UTC 2019 on sn-devel-184 --- diff --git a/lib/texpect/texpect.c b/lib/texpect/texpect.c index 8ced5638c67..32b2fded410 100644 --- a/lib/texpect/texpect.c +++ b/lib/texpect/texpect.c @@ -401,7 +401,7 @@ int main(int argc, const char **argv) { int optidx = 0; pid_t pid; - poptContext pc; + poptContext pc = NULL; const char *instruction_file; const char **args; const char *program; @@ -415,7 +415,7 @@ int main(int argc, const char **argv) if (argc == 1) { poptPrintHelp(pc, stderr, 0); - return 1; + goto out; } while ((optidx = poptGetNextOpt(pc)) != -1) { @@ -426,7 +426,7 @@ int main(int argc, const char **argv) args = poptGetArgs(pc); if (args == NULL) { poptPrintHelp(pc, stderr, 0); - return 1; + goto out; } program_args = (char * const *)discard_const_p(char *, args); @@ -453,7 +453,7 @@ int main(int argc, const char **argv) err(1, "Failed to fork"); /* Never reached */ - return 1; + goto out; case 0: if(setsid()<0) @@ -470,7 +470,7 @@ int main(int argc, const char **argv) err(1, "Failed to exec: %s", program); /* Never reached */ - return 1; + goto out; default: close(slave); { @@ -483,9 +483,13 @@ int main(int argc, const char **argv) sigaction(SIGALRM, &sa, NULL); } + poptFreeContext(pc); return eval_parent(pid); } /* Never reached */ + +out: + poptFreeContext(pc); return 1; }