diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-08-19 11:18:58 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-08-19 11:18:58 +0200 |
commit | ffedc3504b0d1984f46dcbc61da325bbcc9dee0b (patch) | |
tree | e6affcc016fa67c52c6e6667b5b4da932f265744 | |
parent | 895abb449fa9c521098e8135defe4882a0595e9e (diff) | |
download | at-spi2-atk-ffedc3504b0d1984f46dcbc61da325bbcc9dee0b.tar.gz |
Make sure returned values are initialized
Some methods do not have a way to notify that they have failed.
They should thus make sure that they set some value, rather than let them
uninitialized and thus random.
As newly documented by https://gitlab.gnome.org/GNOME/atk/merge_requests/22
-rw-r--r-- | atk-adaptor/adaptors/socket-adaptor.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/atk-adaptor/adaptors/socket-adaptor.c b/atk-adaptor/adaptors/socket-adaptor.c index ed6faa3..c81b2d8 100644 --- a/atk-adaptor/adaptors/socket-adaptor.c +++ b/atk-adaptor/adaptors/socket-adaptor.c @@ -76,14 +76,24 @@ atspi_plug_component_get_extents (AtkComponent *component, gint *x, gint *y, message, -1, &error); dbus_message_unref (message); if (!reply) - return; + { + *x = -1; + *y = -1; + *width = -1; + *height = -1; + return; + } signature = dbus_message_get_signature (reply); if (g_strcmp0 (signature, "(iiii)") != 0) - { - g_warning ("Got unexpected signature %s from GetExtents\n", signature); - dbus_message_unref (reply); - return; - } + { + g_warning ("Got unexpected signature %s from GetExtents\n", signature); + dbus_message_unref (reply); + *x = -1; + *y = -1; + *width = -1; + *height = -1; + return; + } dbus_message_iter_init (reply, &iter); dbus_message_iter_recurse (&iter, &iter_struct); dbus_message_iter_get_basic (&iter_struct, &tmp); @@ -116,12 +126,18 @@ atspi_plug_component_get_position (AtkComponent *component, gint *x, gint *y, message, -1, &error); dbus_message_unref (message); if (!reply) - return; + { + *x = -1; + *y = -1; + return; + } if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_INT32, &x_dbus, DBUS_TYPE_INT32, &y_dbus, DBUS_TYPE_INVALID)) { g_warning ("GetPosition failed: %s", error.message); dbus_error_free (&error); + *x = -1; + *y = -1; } else { @@ -145,12 +161,18 @@ atspi_plug_component_get_size (AtkComponent *component, message, -1, &error); dbus_message_unref (message); if (!reply) - return; + { + *width = -1; + *height = -1; + return; + } if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_INT32, &width_dbus, DBUS_TYPE_INT32, &height_dbus, DBUS_TYPE_INVALID)) { g_warning ("GetSize failed: %s", error.message); dbus_error_free (&error); + *width = -1; + *height = -1; } else { |