summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2010-12-02 15:13:28 +0000
committerSimon McVittie <smcv@debian.org>2010-12-02 15:13:28 +0000
commitdb66571902a3406fc58ac453d8bfa7f689f46c42 (patch)
tree177aa0608076218f7fc27eff3311143f4c2903a6
parent3813781fec33ed3cf33cedbfe7d1ecaf8af34aee (diff)
downloaddbus-python-db66571902a3406fc58ac453d8bfa7f689f46c42.tar.gz
_message_iter_append_multi: bail out safely if a struct isn't filled
In newer versions of libdbus, calling dbus_signature_iter_get_current_type when the iterator is pointing at the ')' of a struct trips an assertion failure, rather than just returning INVALID.
-rw-r--r--_dbus_bindings/message-append.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/_dbus_bindings/message-append.c b/_dbus_bindings/message-append.c
index 981e45a..a6e096f 100644
--- a/_dbus_bindings/message-append.c
+++ b/_dbus_bindings/message-append.c
@@ -653,6 +653,7 @@ _message_iter_append_multi(DBusMessageIter *appender,
goto out;
}
ret = 0;
+ more = TRUE;
while ((contents = PyIter_Next(iterator))) {
if (mode == DBUS_TYPE_ARRAY || mode == DBUS_TYPE_DICT_ENTRY) {
@@ -670,6 +671,14 @@ _message_iter_append_multi(DBusMessageIter *appender,
}
#endif
}
+ else /* struct */ {
+ if (!more) {
+ PyErr_Format(PyExc_TypeError, "Fewer items found in struct's "
+ "D-Bus signature than in Python arguments ");
+ ret = -1;
+ break;
+ }
+ }
if (mode == DBUS_TYPE_DICT_ENTRY) {
ret = _message_iter_append_dictentry(&sub_appender, &sub_sig_iter,