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 6a3a708 commit 446f580Copy full SHA for 446f580
Modules/_sqlite/cursor.c
@@ -1367,8 +1367,15 @@ pysqlite_cursor_close_impl(pysqlite_Cursor *self)
1367
return NULL;
1368
}
1369
1370
- if (self->statement && stmt_reset(self->statement) != SQLITE_OK) {
1371
- cursor_cannot_reset_stmt_error(self, 0);
+ if (self->statement) {
+ int rc = stmt_reset(self->statement);
1372
+ // Force self->statement to be NULL even if stmt_reset() may have
1373
+ // failed to avoid a possible double-free if someone calls close()
1374
+ // twice as a leak here would be better than a double-free.
1375
+ Py_CLEAR(self->statement);
1376
+ if (rc != SQLITE_OK) {
1377
+ cursor_cannot_reset_stmt_error(self, 0);
1378
+ }
1379
1380
1381
0 commit comments