From 61e2493b8341be74928872ce6d7fb3a350bd1697 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 12 Feb 2014 10:52:35 +0200 Subject: Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair. Based on patch by Stephen Tu. --- Modules/_io/bufferedio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Modules') diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 3afe7b17f8..c28e289277 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2263,9 +2263,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; -- cgit v1.2.1