File tree 4 files changed +141
-111
lines changed
4 files changed +141
-111
lines changed Original file line number Diff line number Diff line change 1
- Copyright 2011-2018 Howard Chu, Symas Corp.
1
+ Copyright 2011-2021 Howard Chu, Symas Corp.
2
2
All rights reserved.
3
3
4
4
Redistribution and use in source and binary forms, with or without
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
/* *
Original file line number Diff line number Diff line change @@ -610,7 +610,7 @@ int mdb_env_create(MDB_env **env);
610
610
* <li>#MDB_NOTLS
611
611
* Don't use Thread-Local Storage. Tie reader locktable slots to
612
612
* #MDB_txn objects instead of to threads. I.e. #mdb_txn_reset() keeps
613
- * the slot reseved for the #MDB_txn object. A thread may use parallel
613
+ * the slot reserved for the #MDB_txn object. A thread may use parallel
614
614
* read-only transactions. A read-only transaction may span threads if
615
615
* the user synchronizes its use. Applications that multiplex many
616
616
* user threads over individual OS threads need this option. Such an
@@ -968,7 +968,7 @@ void *mdb_env_get_userctx(MDB_env *env);
968
968
typedef void MDB_assert_func (MDB_env * env , const char * msg );
969
969
970
970
/** Set or reset the assert() callback of the environment.
971
- * Disabled if liblmdb is buillt with NDEBUG.
971
+ * Disabled if liblmdb is built with NDEBUG.
972
972
* @note This hack should become obsolete as lmdb's error handling matures.
973
973
* @param[in] env An environment handle returned by #mdb_env_create().
974
974
* @param[in] func An #MDB_assert_func function, or 0.
You can’t perform that action at this time.
0 commit comments