Skip to content

Commit b867b5e

Browse files
committed
Fix memory leak
1 parent 13b5c9e commit b867b5e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hdr/sqlite_modern_cpp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ namespace sqlite {
296296
database(std::u16string const & db_name): _db(nullptr) {
297297
sqlite3* tmp = nullptr;
298298
auto ret = sqlite3_open16(db_name.data(), &tmp);
299+
_db = std::shared_ptr<sqlite3>(tmp, [=](sqlite3* ptr) { sqlite3_close_v2(ptr); }); // this will close the connection eventually when no longer needed.
299300
if(ret != SQLITE_OK) exceptions::throw_sqlite_error(ret);
300301

301-
_db = std::shared_ptr<sqlite3>(tmp, [=](sqlite3* ptr) { sqlite3_close_v2(ptr); }); // this will close the connection eventually when no longer needed.
302302

303303
//_db.reset(tmp, sqlite3_close); // alternative close. (faster?)
304304
}

0 commit comments

Comments
 (0)