mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Fix to double free segfault in cursor
This commit is contained in:
parent
5db66038fe
commit
85fdc828e7
|
@ -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.
|
||||
|
||||
|
|
|
@ -1661,7 +1661,7 @@ static int
|
|||
cursor_setup(cursorObject *self, connectionObject *conn, const char *name)
|
||||
{
|
||||
Dprintf("cursor_setup: init cursor object at %p", self);
|
||||
Dprintf("cursor_setup: parameters: name = %s, conn = %p", name, conn);
|
||||
Dprintf("cursor_setup: parameters: name = %s, conn = %p", name, conn);
|
||||
|
||||
if (name) {
|
||||
self->name = PyMem_Malloc(strlen(name)+1);
|
||||
|
@ -1717,6 +1717,8 @@ static void
|
|||
cursor_dealloc(PyObject* obj)
|
||||
{
|
||||
cursorObject *self = (cursorObject *)obj;
|
||||
|
||||
PyObject_GC_UnTrack(self);
|
||||
|
||||
if (self->name) PyMem_Free(self->name);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user