]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18408: Fix PyCStructUnionType_update_stgdict(), handle
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 02:50:45 +0000 (03:50 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 02:50:45 +0000 (03:50 +0100)
_ctypes_alloc_format_string() failure

Modules/_ctypes/stgdict.c

index 25d999626a1cab044c31a9c39c22593da91db5b9..b95b0a4231787539c7b933af4b33dfa125f23aaf 100644 (file)
@@ -417,6 +417,8 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
            that). Use 'B' for bytes. */
         stgdict->format = _ctypes_alloc_format_string(NULL, "B");
     }
+    if (stgdict->format == NULL)
+        return -1;
 
 #define realdict ((PyObject *)&stgdict->dict)
     for (i = 0; i < len; ++i) {
@@ -483,7 +485,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
             char *fieldfmt = dict->format ? dict->format : "B";
             char *fieldname = _PyUnicode_AsString(name);
             char *ptr;
-            Py_ssize_t len; 
+            Py_ssize_t len;
             char *buf;
 
             if (fieldname == NULL)