mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +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>
|
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
|
* psycopg/connection_type.c: patch from Gangadharan to avoid double
|
||||||
free of the connection object when calling close() implicitly.
|
free of the connection object when calling close() implicitly.
|
||||||
|
|
||||||
|
|
|
@ -1718,6 +1718,8 @@ cursor_dealloc(PyObject* obj)
|
||||||
{
|
{
|
||||||
cursorObject *self = (cursorObject *)obj;
|
cursorObject *self = (cursorObject *)obj;
|
||||||
|
|
||||||
|
PyObject_GC_UnTrack(self);
|
||||||
|
|
||||||
if (self->name) PyMem_Free(self->name);
|
if (self->name) PyMem_Free(self->name);
|
||||||
|
|
||||||
Py_CLEAR(self->conn);
|
Py_CLEAR(self->conn);
|
||||||
|
@ -1734,8 +1736,7 @@ cursor_dealloc(PyObject* obj)
|
||||||
|
|
||||||
Dprintf("cursor_dealloc: deleted cursor object at %p, refcnt = "
|
Dprintf("cursor_dealloc: deleted cursor object at %p, refcnt = "
|
||||||
FORMAT_CODE_PY_SSIZE_T,
|
FORMAT_CODE_PY_SSIZE_T,
|
||||||
obj, obj->ob_refcnt
|
obj, obj->ob_refcnt);
|
||||||
);
|
|
||||||
|
|
||||||
obj->ob_type->tp_free(obj);
|
obj->ob_type->tp_free(obj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user