summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Szyndela <adrian.s@samsung.com>2017-04-07 18:35:58 +0200
committerAdrian Szyndela <adrian.s@samsung.com>2017-04-07 18:39:57 +0200
commit1d825017e4c6766fc5aee6520f6655333cf72d29 (patch)
tree1aedd972a0d9e2943c7f0b4c28201d175aea8d0c
parentca4bac5403a96780459eea64f36f45c773bb4ed4 (diff)
downloaddbus-1d825017e4c6766fc5aee6520f6655333cf72d29.tar.gz
dbus-1d825017e4c6766fc5aee6520f6655333cf72d29.tar.bz2
dbus-1d825017e4c6766fc5aee6520f6655333cf72d29.zip
GVariant: don't remove padding from no fieldsubmit/tizen/20170410.050637accepted/tizen/unified/20170410.155846
When a message is created with dbus_message_new() it gets no fields. Then, while appending some values, but before setting path, interface, etc. a single field appears - signature. If there would be more fields, then after deleting the last field we would need to remove padding from second-to-last field. In case of a single field, we have no second-to-last field, only empty dictionary. Empty dictionaries do not have padding at the end, so we do not need to remove it. Change-Id: Idb15f3999a3ff0117f906ec632f462eb5cdaab09
-rw-r--r--dbus/dbus-marshal-gvariant.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/dbus/dbus-marshal-gvariant.c b/dbus/dbus-marshal-gvariant.c
index 1348965e..d6a32540 100644
--- a/dbus/dbus-marshal-gvariant.c
+++ b/dbus/dbus-marshal-gvariant.c
@@ -488,10 +488,12 @@ _dbus_header_gvariant_delete_field (DBusHeader *header,
}
n_fields_offsets--;
- /* remove padding from now-last field */
- _dbus_string_shorten (&header->data,
- _dbus_string_get_length(&header->data) -
- (FIRST_GVARIANT_FIELD_OFFSET + fields_offsets[n_fields_offsets-1]));
+ /* remove padding from now-last field, if there is still any field */
+ if (n_fields_offsets > 0)
+ _dbus_string_shorten (&header->data,
+ _dbus_string_get_length(&header->data) -
+ (FIRST_GVARIANT_FIELD_OFFSET + fields_offsets[n_fields_offsets-1]));
+
header->padding = 0;
}
}