Issue #18408: Fix PyUnicode_AsUTF8AndSize(), raise MemoryError exception on

memory allocation failure
This commit is contained in:
Victor Stinner 2013-10-29 01:28:23 +01:00
parent 41bb43a71e
commit a5afb58986
1 changed files with 1 additions and 0 deletions

View File

@ -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;
}