* psycopg/connection_int.c (conn_notice_callback): don't leak

notice messages.
This commit is contained in:
James Henstridge 2008-03-19 01:01:26 +00:00
parent 8103f44a12
commit af1478feb9
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2008-03-19 James Henstridge <james@jamesh.id.au>
* psycopg/connection_int.c (conn_notice_callback): don't leak
notice messages.
2008-03-17 Federico Di Gregorio <fog@initd.org> 2008-03-17 Federico Di Gregorio <fog@initd.org>
* psycopg/adapter_datetime.c: fixed double decref when using * psycopg/adapter_datetime.c: fixed double decref when using

View File

@ -46,7 +46,10 @@ conn_notice_callback(void *args, const char *message)
if (self->protocol < 3 && strncmp(message, "ERROR", 5) == 0) if (self->protocol < 3 && strncmp(message, "ERROR", 5) == 0)
pq_set_critical(self, message); pq_set_critical(self, message);
else { else {
PyList_Append(self->notice_list, PyString_FromString(message)); PyObject *msg = PyString_FromString(message);
PyList_Append(self->notice_list, msg);
Py_DECREF(msg);
/* Remove the oldest item if the queue is getting too long. */ /* Remove the oldest item if the queue is getting too long. */
if (PyList_GET_SIZE(self->notice_list) > CONN_NOTICES_LIMIT) if (PyList_GET_SIZE(self->notice_list) > CONN_NOTICES_LIMIT)