diff options
author | Brett Cannon <brett@python.org> | 2013-07-25 21:34:00 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-07-25 21:34:00 (GMT) |
commit | 845f7845aa6493b59a3b3c427ae85fcd42f58d16 (patch) | |
tree | 63ca42530d27b5df5f8047b5c7a4ca3c02436e37 | |
parent | b76b1b1ec8b26a003c0df330bf6f15a7743f9bed (diff) | |
download | cpython-845f7845aa6493b59a3b3c427ae85fcd42f58d16.zip cpython-845f7845aa6493b59a3b3c427ae85fcd42f58d16.tar.gz cpython-845f7845aa6493b59a3b3c427ae85fcd42f58d16.tar.bz2 |
Issue #18556: Check the return value for PyUnicode_AsWideChar() in
U_set() from ctypes.
CID #486657
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 6 |
2 files changed, 8 insertions, 1 deletions
@@ -52,6 +52,9 @@ Core and Builtins Library ------- +- Issue #18556: Check the return value of a PyUnicode_AsWideChar() call in + ctypes' U_set(). + - Issue #18549: Eliminate dead code in socket_ntohl() - Issue #18514: Fix unreachable Py_DECREF() call in PyCData_FromBaseObj() 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; } |