* psycopg/connection_type.c (connection_dealloc): free

connection->encoding with free() instead of PyMem_Free().

	* psycopg/connection_int.c (conn_connect): use malloc() to
	allocate connection->encoding instead of PyMem_Malloc(), since it
	is freed in other places with free() and assigned to with
	strdup().
This commit is contained in:
James Henstridge 2008-03-30 22:15:21 +00:00
parent e848585b90
commit 23866bc35d
3 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2008-03-31 James Henstridge <james@jamesh.id.au>
* psycopg/connection_type.c (connection_dealloc): free
connection->encoding with free() instead of PyMem_Free().
* psycopg/connection_int.c (conn_connect): use malloc() to
allocate connection->encoding instead of PyMem_Malloc(), since it
is freed in other places with free() and assigned to with
strdup().
2008-03-26 James Henstridge <james@jamesh.id.au>
* psycopg/typecast.c (typecast_from_c): fix up some reference

View File

@ -152,9 +152,9 @@ conn_connect(connectionObject *self)
return -1;
}
tmp = PQgetvalue(pgres, 0, 0);
self->encoding = PyMem_Malloc(strlen(tmp)+1);
self->encoding = malloc(strlen(tmp)+1);
if (self->encoding == NULL) {
/* exception already set by PyMem_Malloc() */
PyErr_NoMemory();
PQfinish(pgconn);
IFCLEARPGRES(pgres);
return -1;

View File

@ -368,7 +368,7 @@ connection_dealloc(PyObject* obj)
if (self->closed == 0) conn_close(self);
if (self->dsn) free(self->dsn);
if (self->encoding) PyMem_Free(self->encoding);
if (self->encoding) free(self->encoding);
if (self->critical) free(self->critical);
Py_XDECREF(self->notice_list);