[Python-checkins] cpython: Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory

victor.stinner python-checkins at python.org
Tue Oct 29 03:51:24 CET 2013


http://hg.python.org/cpython/rev/20cd15a28ad3
changeset:   86722:20cd15a28ad3
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Oct 29 03:50:21 2013 +0100
summary:
  Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory
allocation failure

files:
  Modules/_ctypes/_ctypes.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -278,8 +278,10 @@
     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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list