Fix memory leak
[platform/upstream/at-spi2-core.git] / bus / at-spi-bus-launcher.c
index 3f6c917..db1db5c 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
- * 
- * at-spi-bus-launcher: Manage the a11y bus as a child process 
+ *
+ * at-spi-bus-launcher: Manage the a11y bus as a child process
  *
  * Copyright 2011 Red Hat, Inc.
  *
@@ -124,7 +124,7 @@ setup_bus_child (gpointer data)
 #ifdef __linux
 #include <sys/prctl.h>
   prctl (PR_SET_PDEATHSIG, 15);
-#endif  
+#endif
 }
 
 /**
@@ -156,7 +156,7 @@ on_bus_exited (GPid     pid,
                gpointer data)
 {
   A11yBusLauncher *app = data;
-  
+
   app->a11y_bus_pid = -1;
   app->state = A11Y_BUS_STATE_ERROR;
   if (app->a11y_launch_error_message == NULL)
@@ -169,7 +169,7 @@ on_bus_exited (GPid     pid,
         app->a11y_launch_error_message = g_strdup_printf ("Bus stopped by signal %d", WSTOPSIG (status));
     }
   g_main_loop_quit (app->loop);
-} 
+}
 
 static gboolean
 ensure_a11y_bus (A11yBusLauncher *app)
@@ -181,12 +181,12 @@ ensure_a11y_bus (A11yBusLauncher *app)
 
   if (app->a11y_bus_pid != 0)
     return FALSE;
-  
+
   argv[1] = g_strdup_printf ("--config-file=%s/at-spi2/accessibility.conf", SYSCONFDIR);
 
   if (pipe (app->pipefd) < 0)
     g_error ("Failed to create pipe: %s", strerror (errno));
-  
+
   if (!g_spawn_async (NULL,
                       argv,
                       NULL,
@@ -241,9 +241,12 @@ ensure_a11y_bus (A11yBusLauncher *app)
   }
 #endif
 
+  if (argv[1]) g_free(argv[1]);
+
   return TRUE;
-  
+
  error:
+  if (argv[1]) g_free(argv[1]);
   close (app->pipefd[0]);
   close (app->pipefd[1]);
   app->state = A11Y_BUS_STATE_ERROR;
@@ -379,7 +382,7 @@ handle_set_property  (GDBusConnection       *connection,
   A11yBusLauncher *app = user_data;
   const gchar *type = g_variant_get_type_string (value);
   gboolean enabled;
-  
+
   if (g_strcmp0 (type, "b") != 0)
     {
       g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
@@ -429,7 +432,7 @@ on_bus_acquired (GDBusConnection *connection,
   A11yBusLauncher *app = user_data;
   GError *error;
   guint registration_id;
-  
+
   if (connection == NULL)
     {
       g_main_loop_quit (app->loop);
@@ -506,7 +509,7 @@ on_sigterm_pipe (GIOChannel  *channel,
                  gpointer     data)
 {
   A11yBusLauncher *app = data;
-  
+
   g_main_loop_quit (app->loop);
 
   return FALSE;
@@ -544,7 +547,7 @@ already_running ()
   bridge_display = XOpenDisplay (NULL);
   if (!bridge_display)
              return FALSE;
-      
+
   AT_SPI_BUS = XInternAtom (bridge_display, "AT_SPI_BUS", False);
   XGetWindowProperty (bridge_display,
                      XDefaultRootWindow (bridge_display),
@@ -828,7 +831,7 @@ main (int    argc,
   if (_global_app->a11y_bus_pid > 0)
     kill (_global_app->a11y_bus_pid, SIGTERM);
 
-  /* Clear the X property if our bus is gone; in the case where e.g. 
+  /* Clear the X property if our bus is gone; in the case where e.g.
    * GDM is launching a login on an X server it was using before,
    * we don't want early login processes to pick up the stale address.
    */