diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-01-18 16:29:53 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-05-25 16:13:19 +0100 |
commit | c559ec052541f402d886086bb7b894f256aa8959 (patch) | |
tree | 842301e31ad728a010e88a3ec414f3f801bc5c25 /tools | |
parent | 2ae391ccb388d42f1ac658de01ccbe403920cbfb (diff) | |
download | dbus-c559ec052541f402d886086bb7b894f256aa8959.tar.gz |
dbus-launch: pass_info: always free strings on OOM
This doesn't really do anything, because we're about to exit anyway, but
it placates static analysis tools.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29881
Bug-NB: NB#180486
Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dbus-launch.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index ce9c7b1c..af935386 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -690,10 +690,11 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, int binary_syntax, int argc, char **argv, int remaining_args) { + char *envvar = NULL; + char **args = NULL; + if (runprog) { - char *envvar; - char **args; int i; envvar = malloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") + @@ -701,11 +702,7 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, args = malloc (sizeof (char *) * ((argc-remaining_args)+2)); if (envvar == NULL || args == NULL) - { - free (envvar); - free (args); - goto oom; - } + goto oom; args[0] = xstrdup (runprog); if (!args[0]) @@ -741,6 +738,12 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, close (2); exit (0); oom: + if (envvar) + free (envvar); + + if (args) + free (args); + fprintf (stderr, "Out of memory!"); exit (1); } |