mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-25862: Fix several bugs in the _io module. (GH-8026)
They can be exposed when some C API calls fail due to lack of memory. * Failed Py_BuildValue() could cause an assertion error in the following TextIOWrapper.tell(). * input_chunk could be decrefed twice in TextIOWrapper.seek() after failed Py_BuildValue(). * initvalue could leak in StringIO.__getstate__() after failed PyDict_Copy().
This commit is contained in:
parent
0cdf5f4289
commit
fdb5a50ef3
2 changed files with 17 additions and 8 deletions
|
@ -826,8 +826,10 @@ stringio_getstate(stringio *self, PyObject *Py_UNUSED(ignored))
|
|||
}
|
||||
else {
|
||||
dict = PyDict_Copy(self->dict);
|
||||
if (dict == NULL)
|
||||
if (dict == NULL) {
|
||||
Py_DECREF(initvalue);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
state = Py_BuildValue("(OOnN)", initvalue,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue