From 4ecfd48671b3caab869b72f95ba7c686321af6f1 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 24 Feb 2012 10:50:49 +0000 Subject: [PATCH] Fixed possible NULL dereferencing in notice process --- psycopg/connection_int.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 70465132..cb652249 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -120,8 +120,16 @@ conn_notice_process(connectionObject *self) /* Respect the order in which notices were produced, because in notice_list they are reversed (see ticket #9) */ - PyList_Insert(self->notice_list, nnotices, msg); - Py_DECREF(msg); + if (msg) { + PyList_Insert(self->notice_list, nnotices, msg); + Py_DECREF(msg); + } + else { + /* We don't really have a way to report errors, so gulp it. + * The function should only fail for out of memory, so we are + * likely going to die anyway. */ + PyErr_Clear(); + } notice = notice->next; }