summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-12 08:52:35 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-12 08:52:35 (GMT)
commit61e2493b8341be74928872ce6d7fb3a350bd1697 (patch)
treea9e16cf785c8cd4c54d79c633e11fa64c9857672 /Modules/_io
parent1f9d11b986c95005fbebb724ee3425ad2eb30967 (diff)
downloadcpython-61e2493b8341be74928872ce6d7fb3a350bd1697.zip
cpython-61e2493b8341be74928872ce6d7fb3a350bd1697.tar.gz
cpython-61e2493b8341be74928872ce6d7fb3a350bd1697.tar.bz2
Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/bufferedio.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 3afe7b1..c28e289 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;