atspi_accessible_get_(name|description): fix memory leak 15/254815/1
authorMike Gorse <mgorse@suse.com>
Mon, 22 Feb 2021 21:53:35 +0000 (15:53 -0600)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Tue, 9 Mar 2021 15:09:55 +0000 (16:09 +0100)
This is likely what the backed-out part of !53 was trying to do.

Change-Id: Id6f8bc3eb34caaa8df8a8734a60ce24d7f64aa9f

atspi/atspi-accessible.c

index 958e578..eee40e9 100644 (file)
@@ -340,8 +340,12 @@ gchar *
 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
 {
   g_return_val_if_fail (obj != NULL, g_strdup (""));
+
   if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
   {
+if (obj->name) printf("free\n");
+    g_free (obj->name);
+    obj->name = NULL;
     if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
                                    "s", &obj->name))
       return g_strdup ("");
@@ -886,6 +890,8 @@ atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
 
   if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
   {
+    g_free (obj->description);
+    obj->description = NULL;
     if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
                                    "Description", error, "s",
                                    &obj->description))