mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 21:00:33 +03:00
Consider the case dereferencing weakref in conn_poll returns NULL
It shouldn't but handle the case to avoid a possible null pointer dereferencing.
This commit is contained in:
parent
5b28d7b9c9
commit
4644715164
|
@ -1081,7 +1081,16 @@ conn_poll(connectionObject *self)
|
||||||
/* An async query has just finished: parse the tuple in the
|
/* An async query has just finished: parse the tuple in the
|
||||||
* target cursor. */
|
* target cursor. */
|
||||||
cursorObject *curs;
|
cursorObject *curs;
|
||||||
PyObject *py_curs = PyWeakref_GetObject(self->async_cursor);
|
PyObject *py_curs;
|
||||||
|
if (!(py_curs = PyWeakref_GetObject(self->async_cursor))) {
|
||||||
|
/* It shouldn't happen but consider it to avoid dereferencing
|
||||||
|
* a null pointer below. */
|
||||||
|
pq_clear_async(self);
|
||||||
|
PyErr_SetString(PyExc_SystemError,
|
||||||
|
"got null dereferencing cursor weakref");
|
||||||
|
res = PSYCO_POLL_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (Py_None == py_curs) {
|
if (Py_None == py_curs) {
|
||||||
pq_clear_async(self);
|
pq_clear_async(self);
|
||||||
PyErr_SetString(InterfaceError,
|
PyErr_SetString(InterfaceError,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user