mirror of https://github.com/python/cpython
Issue #18408: Fix PyUnicode_AsUTF8AndSize(), raise MemoryError exception on
memory allocation failure
This commit is contained in:
parent
41bb43a71e
commit
a5afb58986
|
@ -3766,6 +3766,7 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
|
|||
return NULL;
|
||||
_PyUnicode_UTF8(unicode) = PyObject_MALLOC(PyBytes_GET_SIZE(bytes) + 1);
|
||||
if (_PyUnicode_UTF8(unicode) == NULL) {
|
||||
PyErr_NoMemory();
|
||||
Py_DECREF(bytes);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue