From a83050196de5b5e208b797e9528192db5d1564cb Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 4 Jul 2014 17:00:25 -0700 Subject: properly decref the return value of close() --- Modules/_io/_iomodule.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 40acdf5..29db164 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -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); -- cgit v0.12