From 3d3885d15100535f64ddd97f58828cdd933ddd51 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:24:54 +0200 Subject: [PATCH] Add test for #9838 / Remove noisy assert (#4059) * Add test for #9838 * Remove noisy assert --- lib/token.cpp | 2 -- test/testleakautovar.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index 6046cda26..3685dbfd2 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2182,8 +2182,6 @@ bool Token::addValue(const ValueFlow::Value &value) // Add value if (it == mImpl->mValues->end()) { - // If the errorPath has gotten this large then there must be something wrong - assert(value.errorPath.size() < 64); ValueFlow::Value v(value); if (v.varId == 0) v.varId = mImpl->mVarId; diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 8d6d17c01..310ea2059 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -728,6 +728,15 @@ private: " }\n" "};\n", /*cpp*/ true); ASSERT_EQUALS("", errout.str()); + + check("int g(int *p) {\n" // #9838 + " std::unique_ptr temp(p);\n" + " return DoSomething(p);\n" + "}\n" + "int f() {\n" + " return g(new int(3));\n" + "}\n", /*cpp*/ true); + ASSERT_EQUALS("", errout.str()); } void doublefree1() { // #3895