summaryrefslogtreecommitdiff
path: root/msgpack/unpack.h
diff options
context:
space:
mode:
authorSteeve Morin <steeve.morin@gmail.com>2012-02-28 15:36:58 +0100
committerSteeve Morin <steeve.morin@gmail.com>2012-02-28 15:36:58 +0100
commit31b7fda17b464176c34908da366bed5e4545823d (patch)
tree476bb6dcd1cdf57ffe47ca258bcd3e8ba388ab29 /msgpack/unpack.h
parent3a472b1624479ec6a196ac654137dbadc14761a9 (diff)
downloadmsgpack-python-31b7fda17b464176c34908da366bed5e4545823d.tar.gz
Fix massive memory leak with object_hook and list_hook when unpacking.
Diffstat (limited to 'msgpack/unpack.h')
-rw-r--r--msgpack/unpack.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/msgpack/unpack.h b/msgpack/unpack.h
index 0586ca8..6b443f2 100644
--- a/msgpack/unpack.h
+++ b/msgpack/unpack.h
@@ -161,8 +161,10 @@ static inline int template_callback_array_end(unpack_user* u, msgpack_unpack_obj
{
if (u->list_hook) {
PyObject *arglist = Py_BuildValue("(O)", *c);
- *c = PyEval_CallObject(u->list_hook, arglist);
+ msgpack_unpack_object *new_c = PyEval_CallObject(u->list_hook, arglist);
Py_DECREF(arglist);
+ Py_DECREF(*c);
+ *c = new_c;
}
return 0;
}
@@ -190,8 +192,10 @@ static inline int template_callback_map_end(unpack_user* u, msgpack_unpack_objec
{
if (u->object_hook) {
PyObject *arglist = Py_BuildValue("(O)", *c);
- *c = PyEval_CallObject(u->object_hook, arglist);
+ msgpack_unpack_object *new_c = PyEval_CallObject(u->object_hook, arglist);
Py_DECREF(arglist);
+ Py_DECREF(*c);
+ *c = new_c;
}
return 0;
}