Commit 4565c37d authored by Benjamin Peterson's avatar Benjamin Peterson

properly decref the return value of close()

parent d34beba7
......@@ -526,11 +526,13 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds)
error:
if (result != NULL) {
PyObject *exc, *val, *tb;
PyObject *exc, *val, *tb, *close_result;
PyErr_Fetch(&exc, &val, &tb);
if (PyObject_CallMethod(result, "close", NULL) != NULL)
close_result = PyObject_CallMethod(result, "close", NULL);
if (close_result != NULL) {
Py_DECREF(close_result);
PyErr_Restore(exc, val, tb);
else {
} else {
Py_XDECREF(exc);
Py_XDECREF(val);
Py_XDECREF(tb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment