check the result of PyByteArray_Resize in readline() (closes #27211)

This commit is contained in:
Benjamin Peterson 2016-06-03 22:20:44 -07:00
parent bbf29ee6e4
commit a48aa85da0
2 changed files with 6 additions and 1 deletions

View File

@ -89,6 +89,8 @@ Core and Builtins
Library
-------
- Issue #27211: Fix possible memory corruption in io.IOBase.readline().
- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
PermissionError

View File

@ -529,7 +529,10 @@ iobase_readline(PyObject *self, PyObject *args)
}
old_size = PyByteArray_GET_SIZE(buffer);
PyByteArray_Resize(buffer, old_size + PyBytes_GET_SIZE(b));
if (PyByteArray_Resize(buffer, old_size + PyBytes_GET_SIZE(b)) < 0) {
Py_DECREF(b);
goto fail;
}
memcpy(PyByteArray_AS_STRING(buffer) + old_size,
PyBytes_AS_STRING(b), PyBytes_GET_SIZE(b));