]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2006-02-16 Robert McQueen <robot101@debian.org>
authorRobert McQueen <robot101@debian.org>
Thu, 16 Feb 2006 00:43:41 +0000 (00:43 +0000)
committerRobert McQueen <robot101@debian.org>
Thu, 16 Feb 2006 00:43:41 +0000 (00:43 +0000)
* dbus/dbus-message.c (dbus_message_iter_get_fixed_array):
Patch from Rob Taylor <rob.taylor@collabora.co.uk> to correct a bogus
assertion that the next element to read from the iter is fixed in
size. This is not the case when you are at the end of the iter,
because the next element type is INVALID.

* dbus/dbus-string.c (_dbus_string_init_const_len): Correct a
a bogus assert which means that you may not initialise a 0-length
string unless you provide a non-NULL pointer. This prevented
you from marshalling messages containing zero-length arrays in
some cases.

* glib/dbus-gvalue.c (demarshal_collection_array): Another patch
from Rob to correct bogus asserts when trying to demarshal an
array and get_fixed_array got you 0 elements. Append nothing to
the GArray in this case.

* test/glib/test-dbus-glib.c: Add a test case for round-tripping
an empty array via the glib bindings. Without all of the above
patches, this new test fails.

ChangeLog
dbus/dbus-message.c
dbus/dbus-string.c
glib/dbus-gvalue.c
test/glib/test-dbus-glib.c

index 2b15156558d261fb6c7dfb8b58f96d512fdf3eb0..8849ddca091026d4ea27edd55cced6f7afd552ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2006-02-16  Robert McQueen  <robot101@debian.org>
+
+       * dbus/dbus-message.c (dbus_message_iter_get_fixed_array):
+       Patch from Rob Taylor <rob.taylor@collabora.co.uk> to correct a bogus
+       assertion that the next element to read from the iter is fixed in
+       size. This is not the case when you are at the end of the iter,
+       because the next element type is INVALID.
+
+       * dbus/dbus-string.c (_dbus_string_init_const_len): Correct a
+       a bogus assert which means that you may not initialise a 0-length
+       string unless you provide a non-NULL pointer. This prevented
+       you from marshalling messages containing zero-length arrays in
+       some cases.
+
+       * glib/dbus-gvalue.c (demarshal_collection_array): Another patch
+       from Rob to correct bogus asserts when trying to demarshal an
+       array and get_fixed_array got you 0 elements. Append nothing to
+       the GArray in this case.
+
+       * test/glib/test-dbus-glib.c: Add a test case for round-tripping
+       an empty array via the glib bindings. Without all of the above
+       patches, this new test fails.
+
 2006-02-16  Robert McQueen  <robot101@debian.org>
 
        * glib/dbus-gmain.c: Make the previous commit compile.
index eb0e86ccd386c66159a260525a72daea5faced19..06c75b0697ff5b91e280a2b8a9df00151a87019b 100644 (file)
@@ -1735,10 +1735,12 @@ dbus_message_iter_get_fixed_array (DBusMessageIter  *iter,
                                    int              *n_elements)
 {
   DBusMessageRealIter *real = (DBusMessageRealIter *)iter;
+  int subtype = _dbus_type_reader_get_current_type(&real->u.reader);
 
   _dbus_return_if_fail (_dbus_message_iter_check (real));
   _dbus_return_if_fail (value != NULL);
-  _dbus_return_if_fail (dbus_type_is_fixed (_dbus_type_reader_get_current_type (&real->u.reader)));
+  _dbus_return_if_fail ((subtype == DBUS_TYPE_INVALID) ||
+                         dbus_type_is_fixed (subtype));
 
   _dbus_type_reader_read_fixed_multi (&real->u.reader,
                                       value, n_elements);
index eb5ea91ba546460d449cfd5c5fe04b2bad1a35d4..6bd3d57b0e4c528d4c37c0b851d22b1e50adda02 100644 (file)
@@ -232,7 +232,7 @@ _dbus_string_init_const_len (DBusString *str,
   DBusRealString *real;
   
   _dbus_assert (str != NULL);
-  _dbus_assert (value != NULL);
+  _dbus_assert (len == 0 || value != NULL);
   _dbus_assert (len <= _DBUS_STRING_MAX_MAX_LENGTH);
   _dbus_assert (len >= 0);
   
index 3e8cf1e78a8b13cbba459c2e70b260d459303115..e06a8feeac5814d234ff45af93763c4a1dc8d1a2 100644 (file)
@@ -1081,9 +1081,10 @@ demarshal_collection_array (DBusGValueMarshalCtx    *context,
   dbus_message_iter_get_fixed_array (&subiter,
                                     &msgarray,
                                     &msgarray_len);
-  g_assert (msgarray != NULL);
-  g_assert (msgarray_len >= 0);
-  g_array_append_vals (ret, msgarray, (guint) msgarray_len);
+  g_assert (msgarray != NULL || msgarray_len == 0);
+
+  if (msgarray_len)
+    g_array_append_vals (ret, msgarray, (guint) msgarray_len);
 
   g_value_set_boxed_take_ownership (value, ret);
   
index 0a99eda21fbebff1b72a7c56838ba669200435b8..ebcfaeaa8a4647404c8fb9752628caf702617399 100644 (file)
@@ -759,6 +759,21 @@ main (int argc, char **argv)
 
   run_mainloop ();
 
+  {
+    GArray *array;
+    guint32 arraylen;
+
+    array = g_array_new (FALSE, TRUE, sizeof (guint32));
+
+    arraylen = 0;
+    g_print ("Calling (wrapped) zero-length recursive1\n");
+    if (!org_freedesktop_DBus_Tests_MyObject_recursive1 (proxy, array,
+                                                        &arraylen, &error))
+      lose_gerror ("Failed to complete (wrapped) zero-length recursive1 call", error);
+    if (arraylen != 0)
+      lose ("(wrapped) zero-length recursive1 call returned invalid length %u", arraylen);
+  }
+
   {
     GArray *array;
     guint32 val;