diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-12-13 11:30:54 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-12-13 11:30:54 +0000 |
commit | dc1c98f05d29c5b7464d7ac34ee900066f261a86 (patch) | |
tree | 39a4fa03de931b40619b1ae00f89121712bdb3ab | |
parent | 876c668ecbc7b79aa04218b90e0f8b617d3997ed (diff) | |
download | dbus-python-dc1c98f05d29c5b7464d7ac34ee900066f261a86.tar.gz |
_message_iter_get_pyobject: if UTF-8 from libdbus is invalid, don't crash
Based on part of a patch from Barry Warsaw.
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | _dbus_bindings/message-get-args.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/_dbus_bindings/message-get-args.c b/_dbus_bindings/message-get-args.c index 5f3d89c..032d530 100644 --- a/_dbus_bindings/message-get-args.c +++ b/_dbus_bindings/message-get-args.c @@ -245,9 +245,13 @@ _message_iter_get_pyobject(DBusMessageIter *iter, args, kwargs); } else { - args = Py_BuildValue("(N)", PyUnicode_DecodeUTF8(u.s, - strlen(u.s), - NULL)); + PyObject *unicode; + + unicode = PyUnicode_DecodeUTF8(u.s, strlen(u.s), NULL); + if (!unicode) { + break; + } + args = Py_BuildValue("(N)", unicode); if (!args) { break; } |