diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index c04bf84fd..8c6daffc6 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -58,6 +58,9 @@ bool ExecutionPath::parseCondition(const Token &tok, std::list static const Token *checkExecutionPaths_(const Token *tok, std::list &checks) { + if (!tok || tok->str() == "}" || checks.empty()) + return 0; + const std::auto_ptr check(checks.front()->copy()); for (; tok; tok = tok->next()) diff --git a/test/testother.cpp b/test/testother.cpp index 4eefbcf61..a35808206 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1601,6 +1601,17 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" + "{\n" + " {\n" + " for (int i = 0; i < 10; ++i)\n" + " { }\n" + " }\n" + "\n" + " { }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // macro_for.. checkUninitVar("int foo()\n" "{\n"