]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
check result of PyMem_New
authorBenjamin Peterson <benjamin@python.org>
Fri, 16 Mar 2012 17:21:02 +0000 (12:21 -0500)
committerBenjamin Peterson <benjamin@python.org>
Fri, 16 Mar 2012 17:21:02 +0000 (12:21 -0500)
Python/getargs.c

index 37f1898819a37bd5449ff06b25bba18c3d608a46..268a1134ea644f5db0e5bd600b42beeb7a48a5a3 100644 (file)
@@ -267,6 +267,10 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
     format = formatsave;
 
     freelist.entries = PyMem_New(freelistentry_t, max);
+    if (freelist.entries == NULL) {
+        PyErr_NoMemory();
+        return 0;
+    }
 
     if (compat) {
         if (max == 0) {
@@ -1430,6 +1434,10 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
         continue;
 
     freelist.entries = PyMem_New(freelistentry_t, len);
+    if (freelist.entries == NULL) {
+        PyErr_NoMemory();
+        return 0;
+    }
 
     nargs = PyTuple_GET_SIZE(args);
     nkeywords = (keywords == NULL) ? 0 : PyDict_Size(keywords);