summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/cfield.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index f6f8e4236b..65772cfa45 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;
}