summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-06-01 16:54:18 (GMT)
committerGitHub <noreply@github.com>2020-06-01 16:54:18 (GMT)
commita97011b9b8c8111f42e1e7594081956136d848da (patch)
treec755b7df4d7b1486d323835fb43e4195826a4599 /Modules
parente9684fac5a158be9806304a676e619857520a4dc (diff)
downloadcpython-a97011b9b8c8111f42e1e7594081956136d848da.zip
cpython-a97011b9b8c8111f42e1e7594081956136d848da.tar.gz
cpython-a97011b9b8c8111f42e1e7594081956136d848da.tar.bz2
bpo-39593: Add test on ctypes cfield.c s_set() (GH-18424)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/cfield.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 7f85319..32a2bee 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1263,7 +1263,9 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length)
}
data = PyBytes_AS_STRING(value);
- size = strlen(data); /* XXX Why not Py_SIZE(value)? */
+ // bpo-39593: Use strlen() to truncate the string at the first null character.
+ size = strlen(data);
+
if (size < length) {
/* This will copy the terminating NUL character
* if there is space for it.