diff --git a/ChangeLog b/ChangeLog index 0ba996df..257ce1a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-03-31 James Henstridge + + * 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 * psycopg/typecast.c (typecast_from_c): fix up some reference diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 33df14af..b9d44844 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -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; diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 5c54f160..d9b45417 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -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);