From 078a0a2f0e62fc863fc66a1de98c4c3b43aa7642 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 18 Jan 2011 16:29:53 +0000 Subject: [PATCH 1/2] 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 --- 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 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); } -- 1.7.2.3