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