From: Victor Stinner Date: Thu, 7 Nov 2013 23:29:41 +0000 (+0100) Subject: Issue #19437: Fix _io._IOBase.close(), handle _PyObject_SetAttrId() failure X-Git-Tag: v3.4.0b1~340 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa5bbfaa77a14634a035233a8879351d320bad6c;p=thirdparty%2FPython%2Fcpython.git Issue #19437: Fix _io._IOBase.close(), handle _PyObject_SetAttrId() failure --- diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index b58687e3301a..3da7e5d89c36 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -186,11 +186,16 @@ iobase_close(PyObject *self, PyObject *args) Py_RETURN_NONE; res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL); - _PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True); - if (res == NULL) { + + if (_PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True) < 0) { + Py_XDECREF(res); return NULL; } - Py_XDECREF(res); + + if (res == NULL) + return NULL; + + Py_DECREF(res); Py_RETURN_NONE; }