From: Victor Stinner Date: Tue, 29 Oct 2013 02:50:21 +0000 (+0100) Subject: Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory X-Git-Tag: v3.4.0b1~487 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=68f6adca6dbcf25c5cb3c2c411eaf0f9f6f1e793;p=thirdparty%2FPython%2Fcpython.git Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory allocation failure --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 37da94bcbafd..daba2ba8eaff 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -278,8 +278,10 @@ _ctypes_alloc_format_string(const char *prefix, const char *suffix) if (prefix) len += strlen(prefix); result = PyMem_Malloc(len + 1); - if (result == NULL) + if (result == NULL) { + PyErr_NoMemory(); return NULL; + } if (prefix) strcpy(result, prefix); else