diff options
author | Adrian Szyndela <adrian.s@samsung.com> | 2017-08-07 16:38:00 +0200 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2017-08-08 10:12:31 +0900 |
commit | da21875dc5a917d14c8903304d237610e5714ef0 (patch) | |
tree | d91ba52e92f8a514612a0df2ace55866e698536a | |
parent | 59aae7b82d79848f2f188f8b9bfa15d29cd6addc (diff) | |
download | dbus-da21875dc5a917d14c8903304d237610e5714ef0.tar.gz dbus-da21875dc5a917d14c8903304d237610e5714ef0.tar.bz2 dbus-da21875dc5a917d14c8903304d237610e5714ef0.zip |
GVariant: fix for not having offset for empty arrayssubmit/tizen_4.0/20170828.100005submit/tizen/20170810.123503submit/tizen/20170808.013620accepted/tizen/unified/20170811.021149accepted/tizen/unified/20170808.171336accepted/tizen/4.0/unified/20170828.222508
GVariant requires offsets for variable length struct
members. Empty variable-size arrays which are at the beginning
of a struct have offset 0. However, 0 was used as
the indicator that there should be no offset added.
This patch changes 0 to the impossible value.
Change-Id: Icbc18e87831a20727f142a1218e6736e76bcce82
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
-rw-r--r-- | dbus/dbus-marshal-gvariant.c | 8 | ||||
-rw-r--r-- | dbus/dbus-marshal-gvariant.h | 2 | ||||
-rw-r--r-- | dbus/dbus-marshal-recursive.c | 2 | ||||
-rw-r--r-- | dbus/dbus-message.c | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/dbus/dbus-marshal-gvariant.c b/dbus/dbus-marshal-gvariant.c index d6a32540..825b718c 100644 --- a/dbus/dbus-marshal-gvariant.c +++ b/dbus/dbus-marshal-gvariant.c @@ -1205,7 +1205,7 @@ _dbus_writer_gvariant_add_offset_with_variability (DBusTypeWriter *writer, { check_offsets_in_body_for_adding (writer); - if (*writer->u.root.last_offset != 0) + if (*writer->u.root.last_offset != GVARIANT_LAST_OFFSET_NOT_SET) { write_offset (writer->value_str, *writer->u.root.last_offset, @@ -1215,14 +1215,14 @@ _dbus_writer_gvariant_add_offset_with_variability (DBusTypeWriter *writer, if (!fixed) *writer->u.root.last_offset = writer->value_pos - writer->value_start; else - *writer->u.root.last_offset = 0; + *writer->u.root.last_offset = GVARIANT_LAST_OFFSET_NOT_SET; } else if (DBUS_TYPE_STRUCT == writer->container_type || DBUS_TYPE_DICT_ENTRY == writer->container_type) { check_offsets_for_adding (writer); - if (writer->u.struct_or_dict.last_offset != 0) + if (writer->u.struct_or_dict.last_offset != GVARIANT_LAST_OFFSET_NOT_SET) { prepend_offset (writer->offsets, writer->u.struct_or_dict.last_offset, @@ -1231,7 +1231,7 @@ _dbus_writer_gvariant_add_offset_with_variability (DBusTypeWriter *writer, if (!fixed) writer->u.struct_or_dict.last_offset = writer->value_pos - writer->value_start; else - writer->u.struct_or_dict.last_offset = 0; + writer->u.struct_or_dict.last_offset = GVARIANT_LAST_OFFSET_NOT_SET; } else if (DBUS_TYPE_ARRAY == writer->container_type) { diff --git a/dbus/dbus-marshal-gvariant.h b/dbus/dbus-marshal-gvariant.h index 6802acec..07da4da2 100644 --- a/dbus/dbus-marshal-gvariant.h +++ b/dbus/dbus-marshal-gvariant.h @@ -31,6 +31,8 @@ const DBusString *_dbus_get_gvariant_header_signature_str (void); +#define GVARIANT_LAST_OFFSET_NOT_SET ((size_t)-1) + dbus_bool_t _dbus_header_gvariant_create (DBusHeader *header, int byte_order, int type, diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c index 183afb42..af027edc 100644 --- a/dbus/dbus-marshal-recursive.c +++ b/dbus/dbus-marshal-recursive.c @@ -2015,7 +2015,7 @@ writer_recurse_struct_or_dict_entry (DBusTypeWriter *writer, if (NULL == sub->value_str || !_dbus_string_init (sub->value_str)) return FALSE; sub->value_start = sub->value_pos = 0; - sub->u.struct_or_dict.last_offset = 0; + sub->u.struct_or_dict.last_offset = GVARIANT_LAST_OFFSET_NOT_SET; sub->offsets_size = 1; sub->is_fixed = TRUE; sub->offsets = dbus_new (DBusString, 1); diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 4a1f7949..322155ad 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1403,7 +1403,7 @@ dbus_message_new_empty_header (dbus_bool_t gvariant) message->signature = NULL; message->unique_sender = NULL; - message->gvariant_body_last_offset = 0; + message->gvariant_body_last_offset = GVARIANT_LAST_OFFSET_NOT_SET; message->gvariant_body_last_pos = 0; return message; |