Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.

Based on patch by Stephen Tu.
This commit is contained in:
Serhiy Storchaka 2014-02-12 10:55:07 +02:00
commit 5bdfc51950
3 changed files with 48 additions and 2 deletions

View file

@ -2305,9 +2305,14 @@ bufferedrwpair_dealloc(rwpair *self)
static PyObject *
_forward_call(buffered *self, _Py_Identifier *name, PyObject *args)
{
PyObject *func = _PyObject_GetAttrId((PyObject *)self, name);
PyObject *ret;
PyObject *func, *ret;
if (self == NULL) {
PyErr_SetString(PyExc_ValueError,
"I/O operation on uninitialized object");
return NULL;
}
func = _PyObject_GetAttrId((PyObject *)self, name);
if (func == NULL) {
PyErr_SetString(PyExc_AttributeError, name->string);
return NULL;