From 6e464c67ebc7824243710a33453b3a1670c507ae Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 17 Oct 2021 14:32:58 -0400 Subject: [PATCH] Fix a failure-path memory leak in PatchDB (#5269) Closes #5268 --- src/common/PatchDB.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/PatchDB.cpp b/src/common/PatchDB.cpp index 1d55fec40f9..0fa56ed3521 100644 --- a/src/common/PatchDB.cpp +++ b/src/common/PatchDB.cpp @@ -460,6 +460,13 @@ CREATE TABLE IF NOT EXISTS Favorites ( // clean up all the prepared statements if (dbh) sqlite3_close(dbh); + dbh = nullptr; + } + + if (rodbh) + { + sqlite3_close(rodbh); + rodbh = nullptr; } } @@ -973,6 +980,8 @@ CREATE TABLE IF NOT EXISTS Favorites ( << "'. The error was '" << sqlite3_errmsg(dbh) << "'."; storage->reportError(oss.str(), "Surge Patch Database Error"); } + if (rodbh) + sqlite3_close(rodbh); rodbh = nullptr; } }