Fix to double free segfault in cursor

This commit is contained in:
Federico Di Gregorio 2009-04-20 20:19:55 +02:00
parent 5db66038fe
commit 85fdc828e7
2 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,9 @@
2009-04-19 Federico Di Gregorio <fog@initd.org>
* psycopg/cursor_type.c: patch from Gangadharan to avoid double
free of the cursor when the connection that creates it is closed
implicitly by dealloc.
* psycopg/connection_type.c: patch from Gangadharan to avoid double
free of the connection object when calling close() implicitly.

View File

@ -1718,6 +1718,8 @@ cursor_dealloc(PyObject* obj)
{
cursorObject *self = (cursorObject *)obj;
PyObject_GC_UnTrack(self);
if (self->name) PyMem_Free(self->name);
Py_CLEAR(self->conn);
@ -1734,8 +1736,7 @@ cursor_dealloc(PyObject* obj)
Dprintf("cursor_dealloc: deleted cursor object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
obj, obj->ob_refcnt
);
obj, obj->ob_refcnt);
obj->ob_type->tp_free(obj);
}