Kaydet (Commit) 02b8feea authored tarafından Thomas Heller's avatar Thomas Heller

Back out "Patch #1643874: memory leak in ctypes fixed."

The code in this patch leaves no way to give up the ownership of a
BSTR instance.
üst 4d891193
...@@ -287,8 +287,6 @@ Library ...@@ -287,8 +287,6 @@ Library
- Bug #1643943: Fix %U handling for time.strptime. - Bug #1643943: Fix %U handling for time.strptime.
- Patch #1643874: memory leak in ctypes fixed.
- Bug #1598181: Avoid O(N**2) bottleneck in subprocess communicate(). - Bug #1598181: Avoid O(N**2) bottleneck in subprocess communicate().
- Patch #1627441: close sockets properly in urllib2. - Patch #1627441: close sockets properly in urllib2.
......
...@@ -1424,19 +1424,10 @@ Z_get(void *ptr, unsigned size) ...@@ -1424,19 +1424,10 @@ Z_get(void *ptr, unsigned size)
#endif #endif
#ifdef MS_WIN32 #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 * static PyObject *
BSTR_set(void *ptr, PyObject *value, unsigned size) BSTR_set(void *ptr, PyObject *value, unsigned size)
{ {
BSTR bstr; BSTR bstr;
PyObject *result;
/* convert value into a PyUnicodeObject or NULL */ /* convert value into a PyUnicodeObject or NULL */
if (Py_None == value) { if (Py_None == value) {
...@@ -1464,19 +1455,15 @@ BSTR_set(void *ptr, PyObject *value, unsigned size) ...@@ -1464,19 +1455,15 @@ BSTR_set(void *ptr, PyObject *value, unsigned size)
} else } else
bstr = NULL; bstr = NULL;
if (bstr) { /* free the previous contents, if any */
result = PyCObject_FromVoidPtr((void *)bstr, _my_SysFreeString); if (*(BSTR *)ptr)
if (result == NULL) { SysFreeString(*(BSTR *)ptr);
SysFreeString(bstr);
return NULL; /* and store it */
}
} else {
result = Py_None;
Py_INCREF(result);
}
*(BSTR *)ptr = bstr; *(BSTR *)ptr = bstr;
return result;
/* We don't need to keep any other object */
_RET(value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment