summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-07-25 21:36:15 (GMT)
committerBrett Cannon <brett@python.org>2013-07-25 21:36:15 (GMT)
commit5d7c1b1a2b09eb17621201b4b158cdab0b35a0f1 (patch)
tree199edac1321345f8264b5fbf075e2f37fc81c960
parentb41803e3ef65624ce39a4bcf4caff6ff1184699f (diff)
parent845f7845aa6493b59a3b3c427ae85fcd42f58d16 (diff)
downloadcpython-5d7c1b1a2b09eb17621201b4b158cdab0b35a0f1.zip
cpython-5d7c1b1a2b09eb17621201b4b158cdab0b35a0f1.tar.gz
cpython-5d7c1b1a2b09eb17621201b4b158cdab0b35a0f1.tar.bz2
merge for issue #18556
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_ctypes/cfield.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 744d7e1..1dff486 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -166,6 +166,9 @@ Core and Builtins
Library
-------
+- Issue #18556: Check the return type of PyUnicode_AsWideChar() in ctype's
+ U_set().
+
- Issue #17818: aifc.getparams now returns a namedtuple.
- Issue #18549: Eliminate dead code in socket_ntohl()
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index f6f8e42..65772cf 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1260,7 +1260,11 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length)
} else if (size < length-1)
/* copy terminating NUL character if there is space */
size += 1;
- PyUnicode_AsWideChar(value, (wchar_t *)ptr, size);
+
+ if (PyUnicode_AsWideChar(value, (wchar_t *)ptr, size) == -1) {
+ return NULL;
+ }
+
return value;
}