summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-05-10 10:48:51 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-05-10 10:48:51 +0100
commit5157cd12fd7fb0b59d296198174c21596937b9a9 (patch)
treecf27458bac97ca36d160d4f184fab53706f77d6e
parent09d85a945760d06447aea09a38ea99d0dc54de2a (diff)
dbus_g_proxy_end_call_internal: zero out all "out" arguments on entrywip-garbage-out-values-7206-a
FIXME: Code written for this version might crash badly on older dbus-glib; perhaps it'd be better to write invalid pointers through? Bug: https://bugs.freedesktop.org/show_bug.cgi?id=7206
-rw-r--r--dbus/dbus-gproxy.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c
index c683b44..566cb33 100644
--- a/dbus/dbus-gproxy.c
+++ b/dbus/dbus-gproxy.c
@@ -2341,7 +2341,7 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy,
DBusMessage *reply;
DBusMessageIter msgiter;
DBusError derror;
- va_list args_unwind;
+ va_list args_copy;
guint over;
int n_retvals_processed;
gboolean ret;
@@ -2354,8 +2354,39 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy,
n_retvals_processed = 0;
over = 0;
+ G_VA_COPY (args_copy, args);
+
+ for (valtype = first_arg_type;
+ valtype != G_TYPE_INVALID;
+ valtype = va_arg (args_copy, GType))
+ {
+ gpointer return_storage = va_arg (args_copy, gpointer);
+
+ if (return_storage == NULL)
+ continue;
+
+ if (g_type_is_a (valtype, G_TYPE_VALUE))
+ {
+ /* grumble grumble different calling conventions grumble */
+ GValue *value = return_storage;
+
+ memset (value, '\0', sizeof (GValue));
+ }
+ else
+ {
+ GValue value = { 0 };
+
+ g_value_init (&value, valtype);
+
+ if (!_dbus_gvalue_store (&value, return_storage))
+ g_assert_not_reached ();
+ }
+ }
+
+ va_end (args_copy);
+
/* Keep around a copy of output arguments so we can free on error. */
- G_VA_COPY(args_unwind, args);
+ G_VA_COPY(args_copy, args);
pending = g_hash_table_lookup (priv->pending_calls, GUINT_TO_POINTER (call_id));
@@ -2474,7 +2505,7 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy,
g_value_init (&value, valtype);
- retval = va_arg (args_unwind, gpointer);
+ retval = va_arg (args_copy, gpointer);
if (retval == NULL)
{
i--;
@@ -2484,10 +2515,10 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy,
_dbus_gvalue_take (&value, retval);
g_value_unset (&value);
- valtype = va_arg (args_unwind, GType);
+ valtype = va_arg (args_copy, GType);
}
}
- va_end (args_unwind);
+ va_end (args_copy);
va_end (args);
g_hash_table_remove (priv->pending_calls, GUINT_TO_POINTER (call_id));