diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-07-05 00:00:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-07-05 00:00:25 (GMT) |
commit | e865128605faf64c63cd216507a0875e4c5a424b (patch) | |
tree | 93ea6299ce4cb6944e67374e26604e099723eed5 | |
parent | a33bce09451fa6b1b0df89bd131a812631db401b (diff) | |
download | cpython-e865128605faf64c63cd216507a0875e4c5a424b.zip cpython-e865128605faf64c63cd216507a0875e4c5a424b.tar.gz cpython-e865128605faf64c63cd216507a0875e4c5a424b.tar.bz2 |
properly decref the return value of close()
-rw-r--r-- | Modules/_io/_iomodule.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 660ff1f..7c4f9cb 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -465,11 +465,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_CallMethodId(result, &PyId_close, NULL) != NULL) + close_result = _PyObject_CallMethodId(result, &PyId_close, NULL); + if (close_result != NULL) { + Py_DECREF(close_result); PyErr_Restore(exc, val, tb); - else { + } else { PyObject *exc2, *val2, *tb2; PyErr_Fetch(&exc2, &val2, &tb2); PyErr_NormalizeException(&exc, &val, &tb); |