Use PQfreemem to free memory allocated by the libpq.

Bug reported by Anton Kovalev.
This commit is contained in:
Daniele Varrazzo 2010-10-08 14:26:40 +01:00
parent 6e71b3db05
commit 7e482756c5
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,8 @@
2010-10-08 Daniele Varrazzo <daniele.varrazzo@gmail.com> 2010-10-08 Daniele Varrazzo <daniele.varrazzo@gmail.com>
* psycopg/typecast_binary.c: use PQfreemem to free memory allocated by
the libpq. Bug reported by Anton Kovalev.
* dropped PSYCOPG_OWN_QUOTING. * dropped PSYCOPG_OWN_QUOTING.
* psycopg/connection_int.c: Fixed access to freed memory in * psycopg/connection_int.c: Fixed access to freed memory in

View File

@ -41,7 +41,7 @@ chunk_dealloc(chunkObject *self)
FORMAT_CODE_PY_SSIZE_T, FORMAT_CODE_PY_SSIZE_T,
self->base, self->len self->base, self->len
); );
free(self->base); PQfreemem(self->base);
self->ob_type->tp_free((PyObject *) self); self->ob_type->tp_free((PyObject *) self);
} }
@ -176,8 +176,8 @@ typecast_BINARY_cast(const char *s, Py_ssize_t l, PyObject *curs)
Py_DECREF((PyObject *) chunk); Py_DECREF((PyObject *) chunk);
} }
if (str != NULL) { if (str != NULL) {
/* str's mem was allocated by PQunescapeBytea; must use free: */ /* str's mem was allocated by PQunescapeBytea; must use PQfreemem: */
free(str); PQfreemem(str);
} }
if (buffer != NULL) { if (buffer != NULL) {
/* We allocated buffer with PyMem_Malloc; must use PyMem_Free: */ /* We allocated buffer with PyMem_Malloc; must use PyMem_Free: */