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

Skip to content

Commit fc07267

Browse files
Fix ref leak in pysqlite_cursor_iternext
1 parent 2dc3259 commit fc07267

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
@@ -773,29 +773,29 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
773773
if (self->statement) {
774774
rc = pysqlite_step(self->statement->st, self->connection);
775775
if (PyErr_Occurred()) {
776-
(void)pysqlite_statement_reset(self->statement);
777-
Py_DECREF(next_row);
778-
return NULL;
776+
goto error;
779777
}
780778
if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
781-
(void)pysqlite_statement_reset(self->statement);
782-
Py_DECREF(next_row);
783779
_pysqlite_seterror(self->connection->db, NULL);
784-
return NULL;
780+
goto error;
785781
}
786782

787783
if (rc == SQLITE_ROW) {
788784
self->locked = 1; // GH-80254: Prevent recursive use of cursors.
789785
self->next_row = _pysqlite_fetch_one_row(self);
790786
self->locked = 0;
791787
if (self->next_row == NULL) {
792-
(void)pysqlite_statement_reset(self->statement);
793-
return NULL;
788+
goto error;
794789
}
795790
}
796791
}
797792

798793
return next_row;
794+
795+
error:
796+
(void)pysqlite_statement_reset(self->statement);
797+
Py_DECREF(next_row);
798+
return NULL;
799799
}
800800

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

0 commit comments

Comments
 (0)
0