dbus-launch: pass_info: always free strings on OOM
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 18 Jan 2011 16:29:53 +0000 (16:29 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 25 May 2011 15:13:19 +0000 (16:13 +0100)
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>
tools/dbus-launch.c

index ce9c7b1..af93538 100644 (file)
@@ -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);
 }