summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2009-02-10 18:59:04 (GMT)
committerThomas Heller <theller@ctypes.org>2009-02-10 18:59:04 (GMT)
commit465c802044a5d9367997b4030e3435722c811911 (patch)
treefba6d088a6e6772703a6bca5d598b9dddcbf76c3 /Modules
parenta06f44b14345fa95c31e1268367418ffaa87030c (diff)
downloadcpython-465c802044a5d9367997b4030e3435722c811911.zip
cpython-465c802044a5d9367997b4030e3435722c811911.tar.gz
cpython-465c802044a5d9367997b4030e3435722c811911.tar.bz2
(The fix has been slightly adjusted.)
Merged revisions 69505 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69505 | thomas.heller | 2009-02-10 19:43:01 +0100 (Di, 10 Feb 2009) | 3 lines Issue#5203: ctypes segfaults when passing a unicode string to a function without argtypes, if HAVE_USABLE_WCHAR_T is false. ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/callproc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 3bd6d66..c153ae2 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -645,14 +645,15 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
#ifdef CTYPES_UNICODE
if (PyUnicode_Check(obj)) {
- pa->ffi_type = &ffi_type_pointer;
#ifdef HAVE_USABLE_WCHAR_T
+ pa->ffi_type = &ffi_type_pointer;
pa->value.p = PyUnicode_AS_UNICODE(obj);
Py_INCREF(obj);
pa->keep = obj;
return 0;
#else
int size = PyUnicode_GET_SIZE(obj);
+ pa->ffi_type = &ffi_type_pointer;
size += 1; /* terminating NUL */
size *= sizeof(wchar_t);
pa->value.p = PyMem_Malloc(size);