diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-12 08:55:07 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-12 08:55:07 (GMT) |
commit | 5bdfc51950e328c5187fa02a97c0a841196a9e17 (patch) | |
tree | ef2af1b24272871d339d0c759e0ddfd7b4fc7995 /Modules/_io | |
parent | 226c57100c70c42eca199e1c701d5bd17a135cce (diff) | |
parent | 61e2493b8341be74928872ce6d7fb3a350bd1697 (diff) | |
download | cpython-5bdfc51950e328c5187fa02a97c0a841196a9e17.zip cpython-5bdfc51950e328c5187fa02a97c0a841196a9e17.tar.gz cpython-5bdfc51950e328c5187fa02a97c0a841196a9e17.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.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 34c2bb9..7494646 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -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; |