mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
Issue #18408: Fix PyUnicode_AsUTF8AndSize(), raise MemoryError exception on
memory allocation failure
This commit is contained in:
parent
41bb43a71e
commit
a5afb58986
1 changed files with 1 additions and 0 deletions
|
@ -3766,6 +3766,7 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
|
||||||
return NULL;
|
return NULL;
|
||||||
_PyUnicode_UTF8(unicode) = PyObject_MALLOC(PyBytes_GET_SIZE(bytes) + 1);
|
_PyUnicode_UTF8(unicode) = PyObject_MALLOC(PyBytes_GET_SIZE(bytes) + 1);
|
||||||
if (_PyUnicode_UTF8(unicode) == NULL) {
|
if (_PyUnicode_UTF8(unicode) == NULL) {
|
||||||
|
PyErr_NoMemory();
|
||||||
Py_DECREF(bytes);
|
Py_DECREF(bytes);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue