Issue #3660 (part of): fix a memory leak in _pickle.

Patch by Amaury Forgeot d'Arc, review by me.
This commit is contained in:
Antoine Pitrou 2008-09-05 00:03:33 +00:00
parent 9252287f2c
commit d79dc6216c
2 changed files with 7 additions and 1 deletions

View file

@ -3837,13 +3837,17 @@ load_build(UnpicklerObject *self)
if (setstate == NULL) {
if (PyErr_ExceptionMatches(PyExc_AttributeError))
PyErr_Clear();
else
else {
Py_DECREF(state);
return -1;
}
}
else {
PyObject *result;
/* The explicit __setstate__ is responsible for everything. */
/* Ugh... this does not leak since unpickler_call() steals the
reference to state first. */
result = unpickler_call(self, setstate, state);
Py_DECREF(setstate);
if (result == NULL)