Commit da5c4a6
committed
gh-145040: Fix crash in sqlite3 when connection is closed during aggregate callback
Fix a segmentation fault in the _sqlite module that occurs when
Connection.close() is called inside an aggregate step() callback.
After stmt_step() returns, _pysqlite_query_execute() calls
sqlite3_last_insert_rowid(self->connection->db) without checking if
self->connection->db is still valid. If the connection was closed during
the callback, self->connection->db is NULL, causing a NULL pointer
dereference.
The fix adds a NULL check for self->connection->db after stmt_step()
returns, raising ProgrammingError instead of crashing.1 parent 175ab31 commit da5c4a6
3 files changed
Lines changed: 35 additions & 1 deletion
File tree
- Lib/test/test_sqlite3
- Misc/NEWS.d/next/Library
- Modules/_sqlite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
726 | 749 | | |
727 | 750 | | |
728 | 751 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
909 | 914 | | |
910 | 915 | | |
911 | 916 | | |
| |||
967 | 972 | | |
968 | 973 | | |
969 | 974 | | |
970 | | - | |
| 975 | + | |
971 | 976 | | |
972 | 977 | | |
973 | 978 | | |
| |||
0 commit comments