From a5afb58986cc0cd63908f1b5b44d472611f67b4f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 29 Oct 2013 01:28:23 +0100 Subject: [PATCH] Issue #18408: Fix PyUnicode_AsUTF8AndSize(), raise MemoryError exception on memory allocation failure --- Objects/unicodeobject.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ff806cf1a11..87c6472e6a1 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; }