]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 02:50:21 +0000 (03:50 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 02:50:21 +0000 (03:50 +0100)
allocation failure

Modules/_ctypes/_ctypes.c

index 37da94bcbafd2e5bbb254e14c13a527344b7e0f4..daba2ba8eaff7820a401323904bc0120d82949d6 100644 (file)
@@ -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