diff options
author | Thomas Heller <theller@ctypes.org> | 2007-03-09 19:21:28 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2007-03-09 19:21:28 (GMT) |
commit | c2f7725c863e350626d5c27ef56191b7f4104487 (patch) | |
tree | 2afe24e414f4121675b14b3cdbdcb83119428262 /Modules | |
parent | b7b2b4eecfb3437f9da065251f1a35bf9c43db20 (diff) | |
download | cpython-c2f7725c863e350626d5c27ef56191b7f4104487.zip cpython-c2f7725c863e350626d5c27ef56191b7f4104487.tar.gz cpython-c2f7725c863e350626d5c27ef56191b7f4104487.tar.bz2 |
Fix bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0)
returned string up to the first NUL character.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 51658ce..0a90b0a 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -4537,9 +4537,9 @@ create_comerror(void) #endif static PyObject * -string_at(const char *ptr, Py_ssize_t size) +string_at(const char *ptr, int size) { - if (size == 0) + if (size == -1) return PyString_FromString(ptr); return PyString_FromStringAndSize(ptr, size); } @@ -4624,7 +4624,7 @@ cast(void *ptr, PyObject *src, PyObject *ctype) static PyObject * wstring_at(const wchar_t *ptr, int size) { - if (size == 0) + if (size == -1) size = wcslen(ptr); return PyUnicode_FromWideChar(ptr, size); } |