[Python-checkins] cpython: Issue #23765: Remove IsBadStringPtr calls in ctypes
steve.dower
python-checkins at python.org
Wed Mar 25 07:29:12 CET 2015
https://hg.python.org/cpython/rev/585e555247ac
changeset: 95197:585e555247ac
user: Steve Dower <steve.dower at microsoft.com>
date: Tue Mar 24 23:28:54 2015 -0700
summary:
Issue #23765: Remove IsBadStringPtr calls in ctypes
Also renames a local to avoid warnings about shadowing
files:
Modules/_ctypes/cfield.c | 24 ++++--------------------
1 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1354,14 +1354,6 @@
{
/* XXX What about invalid pointers ??? */
if (*(void **)ptr) {
-#if defined(MS_WIN32) && !defined(_WIN32_WCE)
- if (IsBadStringPtrA(*(char **)ptr, -1)) {
- PyErr_Format(PyExc_ValueError,
- "invalid string pointer %p",
- *(char **)ptr);
- return NULL;
- }
-#endif
return PyBytes_FromStringAndSize(*(char **)ptr,
strlen(*(char **)ptr));
} else {
@@ -1418,14 +1410,6 @@
wchar_t *p;
p = *(wchar_t **)ptr;
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 {
Py_INCREF(Py_None);
@@ -1455,15 +1439,15 @@
/* create a BSTR from value */
if (value) {
wchar_t* wvalue;
- Py_ssize_t size;
- wvalue = PyUnicode_AsUnicodeAndSize(value, &size);
+ Py_ssize_t wsize;
+ wvalue = PyUnicode_AsUnicodeAndSize(value, &wsize);
if (wvalue == NULL)
return NULL;
- if ((unsigned) size != size) {
+ if ((unsigned) wsize != wsize) {
PyErr_SetString(PyExc_ValueError, "String too long for BSTR");
return NULL;
}
- bstr = SysAllocStringLen(wvalue, (unsigned)size);
+ bstr = SysAllocStringLen(wvalue, (unsigned)wsize);
Py_DECREF(value);
} else
bstr = NULL;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list