diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-02-05 13:17:12 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-02-05 13:17:12 +0000 |
commit | 95c0d3618041e8c8f9173a3eb8e8ddc93c456952 (patch) | |
tree | c30510c172d71271509794e1bf0b0a2e94297eed /_dbus_bindings | |
parent | 99e0758b1d4f958e5753d51e843f1254e15b93b2 (diff) |
Fix a couple of memory leaks - D-Bus signature strings, and decoded Unicode objects
Diffstat (limited to '_dbus_bindings')
-rw-r--r-- | _dbus_bindings/message-get-args.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/_dbus_bindings/message-get-args.c b/_dbus_bindings/message-get-args.c index dd8d425..cf5a016 100644 --- a/_dbus_bindings/message-get-args.c +++ b/_dbus_bindings/message-get-args.c @@ -118,9 +118,17 @@ _message_iter_get_dict(DBusMessageIter *iter, PyObject *ret; int status; + if (!sig_str) { + PyErr_NoMemory(); + return NULL; + } sig = PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s#)", sig_str+2, (Py_ssize_t)strlen(sig_str)-3); + dbus_free(sig_str); + if (!sig) { + return NULL; + } status = PyDict_SetItem(kwargs, dbus_py_signature_const, sig); Py_DECREF(sig); if (status < 0) { @@ -234,7 +242,7 @@ _message_iter_get_pyobject(DBusMessageIter *iter, args, kwargs); } else { - args = Py_BuildValue("(O)", PyUnicode_DecodeUTF8(u.s, + args = Py_BuildValue("(N)", PyUnicode_DecodeUTF8(u.s, strlen(u.s), NULL)); if (!args) { @@ -453,12 +461,8 @@ _message_iter_get_pyobject(DBusMessageIter *iter, "message", type); } - if (args) { - Py_DECREF(args); - } - if (kwargs) { - Py_DECREF(kwargs); - } + Py_XDECREF(args); + Py_XDECREF(kwargs); return ret; } |