summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-10-29 02:50:45 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-10-29 02:50:45 (GMT)
commitdd371b92c43a98d0df31cd36ed19cf0bb2f94143 (patch)
treed85e6b4cdc381a70edee3e2247d536cc24bc4daa /Modules/_ctypes
parent68f6adca6dbcf25c5cb3c2c411eaf0f9f6f1e793 (diff)
downloadcpython-dd371b92c43a98d0df31cd36ed19cf0bb2f94143.zip
cpython-dd371b92c43a98d0df31cd36ed19cf0bb2f94143.tar.gz
cpython-dd371b92c43a98d0df31cd36ed19cf0bb2f94143.tar.bz2
Issue #18408: Fix PyCStructUnionType_update_stgdict(), handle
_ctypes_alloc_format_string() failure
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/stgdict.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 25d9996..b95b0a4 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -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)