diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-20 06:48:07 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-20 06:48:07 (GMT) |
commit | e20973926a2ec19c4b87e460dc6f0edb478ce352 (patch) | |
tree | cc6843f8f0088c5ee37239afb65faaa0064654c2 /Modules/_ctypes | |
parent | 3c38e066b1a0e600575b2c72207b0f1ac85073cc (diff) | |
parent | 144f77a981ecad8884e1a4e70db72e6fdb609103 (diff) | |
download | cpython-e20973926a2ec19c4b87e460dc6f0edb478ce352.zip cpython-e20973926a2ec19c4b87e460dc6f0edb478ce352.tar.gz cpython-e20973926a2ec19c4b87e460dc6f0edb478ce352.tar.bz2 |
Issue #28715: Added error checks for PyUnicode_AsUTF8().
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 5 | ||||
-rw-r--r-- | Modules/_ctypes/callproc.c | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index b3a9581..65c950e 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -728,8 +728,7 @@ PyCStructType_setattro(PyObject *self, PyObject *key, PyObject *value) return -1; if (value && PyUnicode_Check(key) && - /* XXX struni _PyUnicode_AsString can fail (also in other places)! */ - 0 == strcmp(_PyUnicode_AsString(key), "_fields_")) + _PyUnicode_EqualToASCIIString(key, "_fields_")) return PyCStructUnionType_update_stgdict(self, value, 1); return 0; } @@ -743,7 +742,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value) return -1; if (PyUnicode_Check(key) && - 0 == strcmp(_PyUnicode_AsString(key), "_fields_")) + _PyUnicode_EqualToASCIIString(key, "_fields_")) return PyCStructUnionType_update_stgdict(self, value, 0); return 0; } diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index d3044f3..7d542fb 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1666,7 +1666,9 @@ POINTER(PyObject *self, PyObject *cls) return result; } if (PyUnicode_CheckExact(cls)) { - char *name = _PyUnicode_AsString(cls); + const char *name = PyUnicode_AsUTF8(cls); + if (name == NULL) + return NULL; buf = PyMem_Malloc(strlen(name) + 3 + 1); if (buf == NULL) return PyErr_NoMemory(); |