]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue#5203: ctypes segfaults when passing a unicode string to a
authorThomas Heller <theller@ctypes.org>
Tue, 10 Feb 2009 18:43:01 +0000 (18:43 +0000)
committerThomas Heller <theller@ctypes.org>
Tue, 10 Feb 2009 18:43:01 +0000 (18:43 +0000)
function without argtypes, if HAVE_USABLE_WCHAR_T is false.

Misc/NEWS
Modules/_ctypes/callproc.c

index 536712ab054347892ad31061cde39836f7b7fbc5..a8b5a3cbe7b2858b06f7790f8f23c50bee9a55a1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -152,6 +152,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.
 
index 7f7d641fe2cde5aecbcfa6a6352ae36e8577a0fb..8988c127b3f4383aa9ad1ef0aca175fbba4cad52 100644 (file)
@@ -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);