Fix some memory leaks, initialize a variable, and add a NULL check
authorMario Lang <mlang@debian.org>
Mon, 21 Feb 2011 19:59:16 +0000 (13:59 -0600)
committerMike Gorse <mgorse@novell.com>
Mon, 21 Feb 2011 19:59:16 +0000 (13:59 -0600)
atk-adaptor/accessible-cache.c
cspi/spi-main.c
cspi/spi-registry.c
droute/droute.c

index f282d55..79a369f 100644 (file)
@@ -335,7 +335,7 @@ child_added_listener (GSignalInvocationHint * signal_hint,
       if (signal_hint->detail)
         detail = g_quark_to_string (signal_hint->detail);
 
-      if (!strncmp (detail, "add", 3))
+      if (detail && !strncmp (detail, "add", 3))
         {
           gpointer child;
           int index = g_value_get_uint (param_values + 1);
index e5e58cb..0cbb6bd 100644 (file)
@@ -301,7 +301,11 @@ cspi_get_application (const char *bus_name)
   if (!bus_name_dup) return NULL;
   // TODO: change below to something that will send state-change:defunct notification if necessary */
   app = g_new (CSpiApplication, 1);
-  if (!app) return NULL;
+  if (!app)
+  {
+    g_free (bus_name_dup);
+    return NULL;
+  }
   app->bus_name = bus_name_dup;
   if (APP_IS_REGISTRY (app))
   {
index d6f9469..74716eb 100644 (file)
@@ -151,7 +151,7 @@ SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener  *listener,
                                         AccessibleKeyEventMask        eventmask,
                                         AccessibleKeyListenerSyncType sync_type)
 {
-  gchar *path = cspi_device_listener_get_path (listener);
+  gchar *path;
   gint                                i;
   GArray *key_set;
   dbus_uint32_t key_events = 0;
@@ -164,6 +164,7 @@ SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener  *listener,
     {
       return retval;
     }
+  path = cspi_device_listener_get_path (listener);
 
   /* copy the keyval filter values from the C api into the DBind KeySet */
   if (keys)
@@ -234,7 +235,7 @@ SPIBoolean
 SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
                                           AccessibleKeyMaskType        modmask)
 {
-  gchar *path = cspi_device_listener_get_path (listener);
+  gchar *path;
   Accessibility_ControllerEventMask   controller_event_mask;
   GArray *key_set;
   dbus_uint32_t key_events = 0;
@@ -245,6 +246,7 @@ SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener
       return FALSE;
     }
 
+  path = cspi_device_listener_get_path (listener);
 
   controller_event_mask = (dbus_uint32_t) modmask;
 
@@ -274,7 +276,7 @@ SPI_registerDeviceEventListener (AccessibleDeviceListener  *listener,
   SPIBoolean                          retval = FALSE;
   dbus_uint32_t event_types = 0;
   gint                                i;
-  gchar *path = cspi_device_listener_get_path (listener);
+  gchar *path;
   DBusError error;
 
   if (!listener)
@@ -282,6 +284,8 @@ SPI_registerDeviceEventListener (AccessibleDeviceListener  *listener,
       return retval;
     }
 
+  path = cspi_device_listener_get_path (listener);
+
   /* copy the event filter values from the C api into the CORBA KeyEventTypeSeq */
   
   if (eventmask & SPI_BUTTON_PRESSED)
@@ -315,7 +319,7 @@ SPI_deregisterDeviceEventListener (AccessibleDeviceListener *listener,
                                   void                     *filter)
 {
   dbus_uint32_t event_types = 0;
-  gchar *path = cspi_device_listener_get_path (listener);
+  gchar *path;
   DBusError error;
 
   if (!listener)
@@ -323,6 +327,8 @@ SPI_deregisterDeviceEventListener (AccessibleDeviceListener *listener,
       return FALSE;
     }
 
+  path = cspi_device_listener_get_path (listener);
+
   event_types |= (1 << Accessibility_BUTTON_PRESSED_EVENT);
   event_types |= (1 << Accessibility_BUTTON_RELEASED_EVENT);
 
index ec53ffa..b58402c 100644 (file)
@@ -380,9 +380,12 @@ handle_dbus (DBusConnection *bus,
   char *id_str = (char *) g_malloc(40);
   DBusMessage *reply;
 
-    if (strcmp (iface, DBUS_INTERFACE_DBUS) != 0 ||
-        strcmp (member, "Hello") != 0)
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+  if (strcmp (iface, DBUS_INTERFACE_DBUS) != 0 ||
+      strcmp (member, "Hello") != 0)
+    {
+      g_free (id_str);
+      return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+    }
 
     /* TODO: Fix this hack (we don't handle wrap-around, for instance) */
     sprintf (id_str, ":1.%d", id++);
@@ -403,7 +406,7 @@ handle_properties (DBusConnection *bus,
                    const gchar    *member,
                    const gchar    *pathstr)
 {
-    DBusMessage *reply;
+    DBusMessage *reply = NULL;
     DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
 
     if (!g_strcmp0(member, "GetAll"))