From d4fb5652c099085a11ba769c9db4a62a6ee0bcab Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Sun, 12 Jun 2022 00:17:28 -0500 Subject: [PATCH] Fix 10619: Valueflow: Library function in subfunction does not propagate all values (#4209) --- lib/valueflow.cpp | 2 ++ test/testvalueflow.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 55ff70960..d45209c47 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6820,6 +6820,8 @@ bool productParams(const std::unordered_map>& v for (auto arg:args) { if (value.path != 0) { for (const auto& q:arg) { + if (q.first == p.first) + continue; if (q.second.path == 0) continue; if (q.second.path != value.path) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index dc09943a0..3d48a01fd 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -4398,6 +4398,17 @@ private: "}\n"; ASSERT_EQUALS(true, testValueOfX(code, 7U, 0)); ASSERT_EQUALS(false, testValueOfXKnown(code, 7U, 0)); + + code = "int f(int i) {\n" + " int x = abs(i);\n" + " return x;\n" + "}\n" + "void g() {\n" + " f(1);\n" + " f(0);\n" + "}\n"; + ASSERT_EQUALS(true, testValueOfX(code, 3U, 1)); + ASSERT_EQUALS(true, testValueOfX(code, 3U, 0)); } void valueFlowFunctionReturn() { const char *code;