Skip to content

Commit 5e4908a

Browse files
committed
Fix Transaction destructor exception-safety
The destructor caught only SQLite::Exception, so a std::bad_alloc thrown while building the "ROLLBACK TRANSACTION" string (or any other non-SQLite exception) escaped the implicitly noexcept destructor and called std::terminate. Broaden the handler to catch(...), matching the Savepoint fix (afa51d3). Fixes TXN-08 from the code review.
1 parent afa51d3 commit 5e4908a

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,4 @@ Version 3.4.0 - 2026 ???
310310
- Restore the Coverity Scan static analysis as a GitHub Actions workflow, replacing the old Travis CI job
311311
- Fix Database::getHeaderInfo() signed-shift UB and use fixed-width types for the Header struct (#558)
312312
- Fix Savepoint destructor to catch all exceptions and track rollback state to avoid std::terminate (#559)
313+
- Fix Transaction destructor to catch all exceptions to avoid std::terminate (#559)

src/Transaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Transaction::~Transaction()
5555
{
5656
mDatabase.exec("ROLLBACK TRANSACTION");
5757
}
58-
catch (SQLite::Exception&)
58+
catch (...)
5959
{
6060
// Never throw an exception in a destructor: error if already rollbacked, but no harm is caused by this.
6161
}

0 commit comments

Comments
 (0)