diff options
author | Mattias Andrée <maandree@kth.se> | 2016-08-05 18:19:50 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-08-05 18:19:50 +0200 |
commit | 3e3cf383ae5a0c39e39020c69370c59c27416028 (patch) | |
tree | 6578f0497f797483c70a8f11e2c189b4e0bd381b /src/coopgammad.c | |
parent | Fix signal handlers: restore errno (diff) | |
download | coopgammad-3e3cf383ae5a0c39e39020c69370c59c27416028.tar.gz coopgammad-3e3cf383ae5a0c39e39020c69370c59c27416028.tar.bz2 coopgammad-3e3cf383ae5a0c39e39020c69370c59c27416028.tar.xz |
Fix bugs
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/coopgammad.c')
-rw-r--r-- | src/coopgammad.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/coopgammad.c b/src/coopgammad.c index dd0c9c2..6875849 100644 --- a/src/coopgammad.c +++ b/src/coopgammad.c @@ -558,6 +558,7 @@ static int restore_state(const char* restrict statefile) errno = 0; goto fail; } + free(marshalled), marshalled = NULL; if (connected) { @@ -776,6 +777,7 @@ int main(int argc, char** argv) { int rc = 1, foreground = 0, keep_stderr = 0, query = 0, r; char* statefile = NULL; + char* statefile_ = NULL; ARGBEGIN { @@ -796,7 +798,7 @@ int main(int argc, char** argv) case 'k': keep_stderr = 1; break; case 'q': query = 1 + !!query; break; case ' ': /* Internal, do not document */ - statefile = EARGF(usage()); + statefile = statefile_ = EARGF(usage()); break; default: usage(); @@ -819,10 +821,9 @@ int main(int argc, char** argv) goto fail; else { - if (reexec) + if (statefile != statefile_) free(statefile); unlink(statefile), statefile = NULL; - reexec = 0; /* See `if (reexec && !terminate)` below */ } if (query) @@ -842,8 +843,7 @@ int main(int argc, char** argv) { perror(argv0); fprintf(stderr, "%s: restoring state without re-executing\n", argv0); - /* `reexec = 0;` is done later in case of re-execute failure, - * since it determines whether `statefile` shall be freed. */ + reexec = 0; goto restart; } perror(argv0); |