diff options
| author | Simon McVittie <smcv@debian.org> | 2010-11-23 19:17:19 +0000 |
|---|---|---|
| committer | Simon McVittie <smcv@debian.org> | 2010-11-23 19:17:19 +0000 |
| commit | 53e9cde2ca64de906967546750e5c6dd6aa58da6 (patch) | |
| tree | 9af9c6437c8db9065d12400662ae40f3efb0fce4 /_dbus_bindings/message-get-args.c | |
| parent | 292a9eab92e908b6dc0e97b5ea07c432f41b8bae (diff) | |
| download | dbus-python-53e9cde2ca64de906967546750e5c6dd6aa58da6.tar.gz | |
fd.o #21831: deserialize empty ByteArray objects correctly
For some reason libdbus gives us NULL instead of a pointer to a
zero-length object (i.e. any random place in the message would do), which
Py_BuildValue doesn't interpret the way we'd want it to.
Diffstat (limited to '_dbus_bindings/message-get-args.c')
| -rw-r--r-- | _dbus_bindings/message-get-args.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/_dbus_bindings/message-get-args.c b/_dbus_bindings/message-get-args.c index 7d55ffd..d6b7aba 100644 --- a/_dbus_bindings/message-get-args.c +++ b/_dbus_bindings/message-get-args.c @@ -387,6 +387,12 @@ _message_iter_get_pyobject(DBusMessageIter *iter, dbus_message_iter_get_fixed_array(&sub, (const unsigned char **)&u.s, &n); + if (n == 0 && u.s == NULL) { + /* fd.o #21831: s# turns (NULL, 0) into None, but + * dbus_message_iter_get_fixed_array produces (NULL, 0) + * for an empty byte-blob... */ + u.s = ""; + } args = Py_BuildValue("(s#)", u.s, (Py_ssize_t)n); if (!args) break; ret = PyObject_Call((PyObject *)&DBusPyByteArray_Type, |
