File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1276,12 +1276,11 @@ class lmdb::txn {
1276
1276
* @post `handle() == nullptr`
1277
1277
*/
1278
1278
void commit () {
1279
+ // INDEXSTOREDB START (prevent double free)
1279
1280
MDB_txn *hnd = _handle;
1280
- // Clear _handle before the call otherwise if an error is thrown then
1281
- // the destructor will do abort() which will be double-free since
1282
- // txn_commit will have already freed the handle object.
1283
1281
_handle = nullptr ;
1284
1282
lmdb::txn_commit (hnd);
1283
+ // INDEXSTOREDB END
1285
1284
}
1286
1285
1287
1286
/* *
@@ -1290,8 +1289,11 @@ class lmdb::txn {
1290
1289
* @post `handle() == nullptr`
1291
1290
*/
1292
1291
void abort () noexcept {
1293
- lmdb::txn_abort (_handle);
1292
+ // INDEXSTOREDB START (prevent double free)
1293
+ MDB_txn *hnd = _handle;
1294
1294
_handle = nullptr ;
1295
+ lmdb::txn_abort (hnd);
1296
+ // INDEXSTOREDB END
1295
1297
}
1296
1298
1297
1299
/* *
You can’t perform that action at this time.
0 commit comments