diff options
author | methane <songofacandy@gmail.com> | 2012-02-28 08:19:29 -0800 |
---|---|---|
committer | methane <songofacandy@gmail.com> | 2012-02-28 08:19:29 -0800 |
commit | 02f01f60fcbf2753d36b79500334d9b2379f25b4 (patch) | |
tree | 3542b7c7b01d2e0db51fccd46b43f401e7d46193 | |
parent | 3a472b1624479ec6a196ac654137dbadc14761a9 (diff) | |
parent | a5bc6b73856ca9c59f140427a26a6ffd5103b86f (diff) | |
download | msgpack-python-02f01f60fcbf2753d36b79500334d9b2379f25b4.tar.gz |
Merge pull request #7 from steeve/patch-3
Fix massive memory leak with object_hook and list_hook when unpacking.
-rw-r--r-- | msgpack/unpack.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/msgpack/unpack.h b/msgpack/unpack.h index 0586ca8..2659a97 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); + PyObject *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); + PyObject *new_c = PyEval_CallObject(u->object_hook, arglist); Py_DECREF(arglist); + Py_DECREF(*c); + *c = new_c; } return 0; } |