From 68f6adca6dbcf25c5cb3c2c411eaf0f9f6f1e793 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 29 Oct 2013 03:50:21 +0100 Subject: Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory allocation failure --- Modules/_ctypes/_ctypes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 37da94b..daba2ba 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 -- cgit v0.12