Commit a48aa85d authored by Benjamin Peterson's avatar Benjamin Peterson

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

parent bbf29ee6
......@@ -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
......
......@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment