Skip to content

Commit

Permalink
lib: free popt context in texpect
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]>

Autobuild-User(master): Andrew Bartlett <[email protected]>
Autobuild-Date(master): Thu Aug 22 01:41:37 UTC 2019 on sn-devel-184
  • Loading branch information
sswen authored and abartlet committed Aug 22, 2019
1 parent 5e1c7c0 commit a738388
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/texpect/texpect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -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);
{
Expand All @@ -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;
}

0 comments on commit a738388

Please sign in to comment.