mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 19:03:43 +03:00
Check for failed allocation in the notice callback
This commit is contained in:
parent
343687ebc8
commit
29ac03ef04
|
@ -69,7 +69,15 @@ conn_notice_callback(void *args, const char *message)
|
||||||
*/
|
*/
|
||||||
notice = (struct connectionObject_notice *)
|
notice = (struct connectionObject_notice *)
|
||||||
malloc(sizeof(struct connectionObject_notice));
|
malloc(sizeof(struct connectionObject_notice));
|
||||||
|
if (NULL == notice) {
|
||||||
|
/* Discard the notice in case of failed allocation. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
notice->message = strdup(message);
|
notice->message = strdup(message);
|
||||||
|
if (NULL == notice->message) {
|
||||||
|
free(notice);
|
||||||
|
return;
|
||||||
|
}
|
||||||
notice->next = self->notice_pending;
|
notice->next = self->notice_pending;
|
||||||
self->notice_pending = notice;
|
self->notice_pending = notice;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user