diff options
author | James Henstridge <james@jamesh.id.au> | 2008-03-30 22:15:21 +0000 |
---|---|---|
committer | James Henstridge <james@jamesh.id.au> | 2008-03-30 22:15:21 +0000 |
commit | 23866bc35dd20af7e4c63efe8c4ed06285e4180e (patch) | |
tree | 88fb2565cb813010131c8aeb0ec1273306823332 | |
parent | e848585b90fd82b708757cb319a3fbfd896c233b (diff) | |
download | psycopg2-23866bc35dd20af7e4c63efe8c4ed06285e4180e.tar.gz |
* 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().
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | psycopg/connection_int.c | 4 | ||||
-rw-r--r-- | psycopg/connection_type.c | 2 |
3 files changed, 13 insertions, 3 deletions
@@ -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 diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 33df14a..b9d4484 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 5c54f16..d9b4541 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); |