diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/cfield.c | 29 | ||||
-rw-r--r-- | Modules/posixmodule.c | 2 |
2 files changed, 22 insertions, 9 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index ad83195..799b457 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1432,10 +1432,19 @@ Z_get(void *ptr, unsigned size) #endif #ifdef MS_WIN32 +/* We cannot use SysFreeString as the PyCObject_FromVoidPtr + because of different calling convention +*/ +static void _my_SysFreeString(void *p) +{ + SysFreeString((BSTR)p); +} + static PyObject * BSTR_set(void *ptr, PyObject *value, unsigned size) { BSTR bstr; + PyObject *result; /* convert value into a PyUnicodeObject or NULL */ if (Py_None == value) { @@ -1463,15 +1472,19 @@ BSTR_set(void *ptr, PyObject *value, unsigned size) } else bstr = NULL; - /* free the previous contents, if any */ - if (*(BSTR *)ptr) - SysFreeString(*(BSTR *)ptr); - - /* and store it */ - *(BSTR *)ptr = bstr; + if (bstr) { + result = PyCObject_FromVoidPtr((void *)bstr, _my_SysFreeString); + if (result == NULL) { + SysFreeString(bstr); + return NULL; + } + } else { + result = Py_None; + Py_INCREF(result); + } - /* We don't need to keep any other object */ - _RET(value); + *(BSTR *)ptr = bstr; + return result; } diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f8df0c4..c86a458 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1462,7 +1462,7 @@ posix_do_stat(PyObject *self, PyObject *args, /* POSIX methods */ PyDoc_STRVAR(posix_access__doc__, -"access(path, mode) -> 1 if granted, 0 otherwise\n\n\ +"access(path, mode) -> True if granted, False otherwise\n\n\ Use the real uid/gid to test for access to a path. Note that most\n\ operations will use the effective uid/gid, therefore this routine can\n\ be used in a suid/sgid environment to test if the invoking user has the\n\ |