From 26241f2ec7f6718dc1a10e83c4baf6e45841844d Mon Sep 17 00:00:00 2001 From: Kevin Tran Date: Fri, 11 Oct 2024 10:19:43 -0600 Subject: [PATCH] resolve SQLite3 memory leak in rtc_cache Fixes memory leak caused by db handles that are not deallocated when db open fails. --- library/src/rtc_cache.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/rtc_cache.cpp b/library/src/rtc_cache.cpp index 7a0d7a46..273ebc35 100644 --- a/library/src/rtc_cache.cpp +++ b/library/src/rtc_cache.cpp @@ -108,7 +108,10 @@ sqlite3_ptr RTCCache::connect_db(const fs::path& path, bool readonly) flags |= SQLITE_OPEN_MEMORY; } if(sqlite3_open_v2(path.string().c_str(), &db_raw, flags, nullptr) != SQLITE_OK) + { + sqlite3_close(db_raw); return nullptr; + } sqlite3_ptr db(db_raw);