From 02f0de2a5802105150f4a51eb9a13f4e3ea267f4 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Sun, 9 Feb 2020 13:17:40 +0800 Subject: [PATCH] Use Py_SIZE() in s_set() of cfield.c --- Modules/_ctypes/cfield.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index f860e6e51b2468..b62d4c436384f1 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1293,8 +1293,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length) return NULL; } - data = PyBytes_AS_STRING(value); - size = strlen(data); /* XXX Why not Py_SIZE(value)? */ + size = Py_SIZE(value); if (size < length) { /* This will copy the terminating NUL character * if there is space for it. @@ -1306,6 +1305,8 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length) size, length); return NULL; } + + data = PyBytes_AS_STRING(value); /* Also copy the terminating NUL character if there is space */ memcpy((char *)ptr, data, size); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy