mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-02 02:20:54 +00:00
Merge pull request #7 from steeve/patch-3
Fix massive memory leak with object_hook and list_hook when unpacking.
This commit is contained in:
commit
02f01f60fc
1 changed files with 6 additions and 2 deletions
|
|
@ -161,8 +161,10 @@ static inline int template_callback_array_end(unpack_user* u, msgpack_unpack_obj
|
||||||
{
|
{
|
||||||
if (u->list_hook) {
|
if (u->list_hook) {
|
||||||
PyObject *arglist = Py_BuildValue("(O)", *c);
|
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(arglist);
|
||||||
|
Py_DECREF(*c);
|
||||||
|
*c = new_c;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -190,8 +192,10 @@ static inline int template_callback_map_end(unpack_user* u, msgpack_unpack_objec
|
||||||
{
|
{
|
||||||
if (u->object_hook) {
|
if (u->object_hook) {
|
||||||
PyObject *arglist = Py_BuildValue("(O)", *c);
|
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(arglist);
|
||||||
|
Py_DECREF(*c);
|
||||||
|
*c = new_c;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue