summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-05-02 19:41:16 (GMT)
committerThomas Heller <theller@ctypes.org>2007-05-02 19:41:16 (GMT)
commit412b20bd31bb9c15a1ea64861f24d9f50b7b2b25 (patch)
treeb62313cb0c0358df1dcc7af8d126e7dc296c6182 /Modules
parente5ebbecae3d6e84babc03b92beebe485ca76077f (diff)
downloadcpython-412b20bd31bb9c15a1ea64861f24d9f50b7b2b25.zip
cpython-412b20bd31bb9c15a1ea64861f24d9f50b7b2b25.tar.gz
cpython-412b20bd31bb9c15a1ea64861f24d9f50b7b2b25.tar.bz2
Merged revisions 55027 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Modules/_ctypes ........ r55027 | thomas.heller | 2007-04-30 18:04:57 +0200 (Mo, 30 Apr 2007) | 8 lines When accessing the .value attribute of a c_wchar_p instance, and the instance does not point to a valid wchar_t zero-terminated string, raise a ValueError. c_char_p does this already. The ValueError message now contains the correct pointer address. Will backport to release25-maint. ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/cfield.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 6aa68a8..9fef3e7 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1333,7 +1333,7 @@ z_get(void *ptr, unsigned size)
if (IsBadStringPtrA(*(char **)ptr, -1)) {
PyErr_Format(PyExc_ValueError,
"invalid string pointer %p",
- ptr);
+ *(char **)ptr);
return NULL;
}
#endif
@@ -1414,9 +1414,17 @@ Z_get(void *ptr, unsigned size)
{
wchar_t *p;
p = *(wchar_t **)ptr;
- if (p)
+ if (p) {
+#if defined(MS_WIN32) && !defined(_WIN32_WCE)
+ if (IsBadStringPtrW(*(wchar_t **)ptr, -1)) {
+ PyErr_Format(PyExc_ValueError,
+ "invalid string pointer %p",
+ *(wchar_t **)ptr);
+ return NULL;
+ }
+#endif
return PyUnicode_FromWideChar(p, wcslen(p));
- else {
+ } else {
Py_INCREF(Py_None);
return Py_None;
}