Issue #18408: Fix _ctypes_alloc_format_string(), raise MemoryError on memory

allocation failure
This commit is contained in:
Victor Stinner 2013-10-29 03:50:21 +01:00
parent cc64eb5b9f
commit 68f6adca6d
1 changed files with 3 additions and 1 deletions

View 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