Commit a8305019 authored by Benjamin Peterson's avatar Benjamin Peterson

properly decref the return value of close()

parent 6690eed4
...@@ -526,11 +526,13 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -526,11 +526,13 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds)
error: error:
if (result != NULL) { if (result != NULL) {
PyObject *exc, *val, *tb; PyObject *exc, *val, *tb, *close_result;
PyErr_Fetch(&exc, &val, &tb); 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); PyErr_Restore(exc, val, tb);
else { } else {
Py_XDECREF(exc); Py_XDECREF(exc);
Py_XDECREF(val); Py_XDECREF(val);
Py_XDECREF(tb); 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