8000 Fix ref leak in pysqlite_cursor_iternext · python/cpython@41a21db · GitHub
[go: up one dir, main page]

Skip to content

Commit 41a21db

Browse files
Fix ref leak in pysqlite_cursor_iternext
1 parent a5b9786 commit 41a21db

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Modules/_sqlite/cursor.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -762,29 +762,29 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
762762
if (self->statement) {
763763
rc = pysqlite_step(self->statement->st, self->connection);
764764
if (PyErr_Occurred()) {
765-
(void)pysqlite_statement_reset(self->statement);
766-
Py_DECREF(next_row);
767-
return NULL;
765+
goto error;
768766
}
769767
if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
770-
(void)pysqlite_statement_reset(self->statement);
771-
Py_DECREF(next_row);
772768
_pysqlite_seterror(self->connection->db, NULL);
773-
return NULL;
769+
goto error;
774770
}
775771

776772
if (rc == SQLITE_ROW) {
777773
self->locked = 1; // GH-80254: Prevent recursive use of cursors.
778774
self->next_row = _pysqlite_fetch_one_row(self);
779775
self->locked = 0;
780776
if (self->next_row == NULL) {
781-
(void)pysqlite_statement_reset(self->statement);
782-
return NULL;
777+
goto error;
783778
}
784779
}
785780
}
786781

787782
return next_row;
783+
784+
error:
785+
(void)pysqlite_statement_reset(self->statement);
786+
Py_DECREF(next_row);
787+
return NULL;
788788
}
789789

790790
PyObject* pysqlite_cursor_fetchone(pysqlite_Cursor* self, PyObject* args)

0 commit comments

Comments
 (0)
0