[at-spi2-core] Add some defensive checks to prevent problems with defunct objects



commit d4e6ce638f4178ea9737ff8aa6d10f49dfca4f58
Author: Mike Gorse <mgorse novell com>
Date:   Thu Sep 15 16:41:28 2011 -0500

    Add some defensive checks to prevent problems with defunct objects

 atspi/atspi-collection.c |    2 ++
 atspi/atspi-component.c  |    9 +++++++++
 atspi/atspi-value.c      |    8 ++++++++
 registryd/registry.c     |    2 ++
 4 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/atspi/atspi-collection.c b/atspi/atspi-collection.c
index 210a0cd..a965757 100644
--- a/atspi/atspi-collection.c
+++ b/atspi/atspi-collection.c
@@ -49,6 +49,8 @@ new_message (AtspiCollection *collection, char *method)
     return NULL;
 
   accessible = ATSPI_ACCESSIBLE (collection);
+  if (!accessible->parent.app)
+    return NULL;
   return dbus_message_new_method_call (accessible->parent.app->bus_name,
                                        accessible->parent.path,
                                        atspi_interface_collection,
diff --git a/atspi/atspi-component.c b/atspi/atspi-component.c
index 3c84fb9..24d74d4 100644
--- a/atspi/atspi-component.c
+++ b/atspi/atspi-component.c
@@ -307,10 +307,19 @@ atspi_component_set_extents (AtspiComponent *obj,
 
   g_return_val_if_fail (obj != NULL, FALSE);
 
+  if (!aobj->parent.app || !aobj->parent.app->bus_name)
+  {
+    g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_APPLICATION_GONE,
+                          _("The application no longer exists"));
+    return FALSE;
+  }
+
   message = dbus_message_new_method_call (aobj->parent.app->bus_name,
                                           aobj->parent.path,
                                           atspi_interface_component,
                                           "SetExtents");
+  if (!message)
+    return FALSE;
 
   dbus_message_iter_init_append (message, &iter);
   if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_STRUCT, NULL, &iter_struct))
diff --git a/atspi/atspi-value.c b/atspi/atspi-value.c
index fbd9573..a8df846 100644
--- a/atspi/atspi-value.c
+++ b/atspi/atspi-value.c
@@ -104,6 +104,14 @@ atspi_value_set_current_value (AtspiValue *obj, gdouble new_value, GError **erro
   AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj);
 
   g_return_val_if_fail (accessible != NULL, FALSE);
+
+  if (!accessible->parent.app || !accessible->parent.app->bus_name)
+{
+    g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_APPLICATION_GONE,
+                          _("The application no longer exists"));
+    return FALSE;
+  }
+
     message = dbus_message_new_method_call (accessible->parent.app->bus_name,
                                             accessible->parent.path,
                                             DBUS_INTERFACE_PROPERTIES, "Set");
diff --git a/registryd/registry.c b/registryd/registry.c
index f486fd6..d722f17 100644
--- a/registryd/registry.c
+++ b/registryd/registry.c
@@ -375,6 +375,8 @@ impl_Embed (DBusConnection *bus, DBusMessage *message, void *user_data)
   if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_STRING))
 	goto error;
   dbus_message_iter_get_basic (&iter_struct, &app_name);
+  if (!app_name)
+    app_name = dbus_message_get_sender (message);
   if (!dbus_message_iter_next (&iter_struct))
         goto error;
   if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_OBJECT_PATH))



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