From c559ec052541f402d886086bb7b894f256aa8959 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 18 Jan 2011 16:29:53 +0000 Subject: [PATCH] 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 --- tools/dbus-launch.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index ce9c7b1..af93538 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); } -- 2.7.4