We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b28d7b commit 4644715Copy full SHA for 4644715
psycopg/connection_int.c
@@ -1081,7 +1081,16 @@ conn_poll(connectionObject *self)
1081
/* An async query has just finished: parse the tuple in the
1082
* target cursor. */
1083
cursorObject *curs;
1084
- PyObject *py_curs = PyWeakref_GetObject(self->async_cursor);
+ PyObject *py_curs;
1085
+ if (!(py_curs = PyWeakref_GetObject(self->async_cursor))) {
1086
+ /* It shouldn't happen but consider it to avoid dereferencing
1087
+ * a null pointer below. */
1088
+ pq_clear_async(self);
1089
+ PyErr_SetString(PyExc_SystemError,
1090
+ "got null dereferencing cursor weakref");
1091
+ res = PSYCO_POLL_ERROR;
1092
+ break;
1093
+ }
1094
if (Py_None == py_curs) {
1095
pq_clear_async(self);
1096
PyErr_SetString(InterfaceError,
0 commit comments