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 | 4f654fbe3023caf1b163f7db3064f58921522468 (patch) | |
tree | c40343158c96b25734af7ee6536d7d95fe9f8d0a /Modules/_io | |
parent | c68b7fba86da1a35ecf79d9406171eed38ea62ef (diff) | |
download | cpython-4f654fbe3023caf1b163f7db3064f58921522468.zip cpython-4f654fbe3023caf1b163f7db3064f58921522468.tar.gz cpython-4f654fbe3023caf1b163f7db3064f58921522468.tar.bz2 |
properly decref the return value of close()
Diffstat (limited to 'Modules/_io')
-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 9e14b4f..6f7af41 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -455,11 +455,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); |