From 07750565c99849a4b3963a40e39541b5ae91f5d0 Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Tue, 10 Feb 2009 18:46:11 +0000 Subject: [PATCH] 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. ........ --- Misc/NEWS | 3 +++ Modules/_ctypes/callproc.c | 1 + 2 files changed, 4 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 5057c2d7cde..9176b6c807f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -80,6 +80,9 @@ Core and Builtins Library ------- +- Issue #5203: Fixed ctypes segfaults when passing a unicode string to a + function without argtypes (only occurs if HAVE_USABLE_WCHAR_T is false). + - Issue #3386: distutils.sysconfig.get_python_lib prefix argument was ignored under NT and OS2. Patch by Philip Jenvey. diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 7f7d641fe2c..8988c127b3f 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -664,6 +664,7 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) 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);