aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/coopgammad.c10
-rw-r--r--src/servers/kernel.c10
-rw-r--r--src/state.c1
3 files changed, 10 insertions, 11 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);
diff --git a/src/servers/kernel.c b/src/servers/kernel.c
index 19af912..4ccbe9c 100644
--- a/src/servers/kernel.c
+++ b/src/servers/kernel.c
@@ -52,13 +52,13 @@ static char* get_pathname(const char* restrict suffix)
size_t n;
int saved_errno;
- if (site.site)
+ if (sitename)
{
- name = memdup(site.site, strlen(site.site) + 1);
+ name = memdup(sitename, strlen(sitename) + 1);
if (name == NULL)
goto fail;
}
- else if ((name = libgamma_method_default_site(site.method)))
+ else if ((name = libgamma_method_default_site(method)))
{
name = memdup(name, strlen(name) + 1);
if (name == NULL)
@@ -66,7 +66,7 @@ static char* get_pathname(const char* restrict suffix)
}
if (name != NULL)
- switch (site.method)
+ switch (method)
{
case LIBGAMMA_METHOD_X_RANDR:
case LIBGAMMA_METHOD_X_VIDMODE:
@@ -89,7 +89,7 @@ static char* get_pathname(const char* restrict suffix)
if (!(rc = malloc(n)))
goto fail;
sprintf(rc, "%s/.coopgammad/~%s/%i%s%s%s",
- rundir, username, site.method, name ? "." : "", name ? name : "", suffix);
+ rundir, username, method, name ? "." : "", name ? name : "", suffix);
free(name);
return rc;
diff --git a/src/state.c b/src/state.c
index 71e2146..a9b4b2e 100644
--- a/src/state.c
+++ b/src/state.c
@@ -286,7 +286,6 @@ size_t state_unmarshal(const void* restrict buf)
if (*(bs + off))
{
- off += 1;
n = strlen(bs + off) + 1;
if (!(argv0_real = memdup(bs + off, n)))
return 0;