[at-spi2-atk] Fix some memory leaks, initialize a variable, and add a NULL check



commit b92c3032a60413834b85318e05bc9d0c30f0cefd
Author: Mario Lang <mlang debian org>
Date:   Mon Feb 21 13:59:16 2011 -0600

    Fix some memory leaks, initialize a variable, and add a NULL check

 atk-adaptor/accessible-cache.c |    2 +-
 cspi/spi-main.c                |    6 +++++-
 cspi/spi-registry.c            |   14 ++++++++++----
 droute/droute.c                |   11 +++++++----
 4 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/atk-adaptor/accessible-cache.c b/atk-adaptor/accessible-cache.c
index f282d55..79a369f 100644
--- a/atk-adaptor/accessible-cache.c
+++ b/atk-adaptor/accessible-cache.c
@@ -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);
diff --git a/cspi/spi-main.c b/cspi/spi-main.c
index e5e58cb..0cbb6bd 100644
--- a/cspi/spi-main.c
+++ b/cspi/spi-main.c
@@ -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))
   {
diff --git a/cspi/spi-registry.c b/cspi/spi-registry.c
index d6f9469..74716eb 100644
--- a/cspi/spi-registry.c
+++ b/cspi/spi-registry.c
@@ -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);
 
diff --git a/droute/droute.c b/droute/droute.c
index ec53ffa..b58402c 100644
--- a/droute/droute.c
+++ b/droute/droute.c
@@ -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"))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]