From af5e6d3b29de64ada6bab636245fedd6b5dd6308 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:09:45 +0200 Subject: [PATCH 1/4] Update sqlite3.c --- test/cfg/sqlite3.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/cfg/sqlite3.c b/test/cfg/sqlite3.c index d9480d5ad1d..b941003a48d 100644 --- a/test/cfg/sqlite3.c +++ b/test/cfg/sqlite3.c @@ -46,6 +46,14 @@ void resourceLeak_sqlite3_open() // cppcheck-suppress resourceLeak } +void resourceLeak_sqlite3_open_v2(const char* Filename, int Flags, int Timeout, const char* Vfs) { // #12951, don't crash + sqlite3* handle; + const int ret = sqlite3_open_v2(Filename, &handle, Flags, Vfs); + if (SQLITE_OK != ret) {} + if (Timeout > 0) {} + // cppcheck-suppress resourceLeak +} + void ignoredReturnValue(const char * buf) { // cppcheck-suppress leakReturnValNotUsed From e6dccc1c128d58dfd18ac80f3341555e4776767e Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:12:21 +0200 Subject: [PATCH 2/4] Update checkleakautovar.cpp --- lib/checkleakautovar.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 80a3a862893..18fe7199968 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -526,6 +526,15 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken, if (astIsVariableComparison(tok3, "!=", "0", &vartok) && (notzero.find(vartok->varId()) != notzero.end())) varInfo2.clear(); + + if (std::any_of(varInfo1.alloctype.begin(), varInfo1.alloctype.end(), [&](const std::pair& info) { + if (info.second.status != VarInfo::ALLOC) + return false; + const Token* ret = getReturnValueFromOutparamAlloc(info.second.allocTok, *mSettings); + return ret && vartok && ret->varId() && ret->varId() == vartok->varId(); + })) { + varInfo1.clear(); + } } else if (isVarTokComparison(tok3, &vartok, alloc_failed_conds)) { varInfo1.reallocToAlloc(vartok->varId()); varInfo1.erase(vartok->varId()); From 3fc37818c40beed46f07141feb11663fc11852a3 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:32:24 +0200 Subject: [PATCH 3/4] Update sqlite3.cfg --- cfg/sqlite3.cfg | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cfg/sqlite3.cfg b/cfg/sqlite3.cfg index 6c1053b393f..9ab55685f30 100644 --- a/cfg/sqlite3.cfg +++ b/cfg/sqlite3.cfg @@ -1027,6 +1027,49 @@ + + + + false + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + +