diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 8f929232e..36efe94c6 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1286,6 +1286,8 @@ private: static void use(bool &foundError, std::list &checks, const Token *tok, const int mode) { const unsigned int varid(tok->varId()); + if (varid == 0) + return; std::list::const_iterator it; for (it = checks.begin(); it != checks.end(); ++it) diff --git a/test/testother.cpp b/test/testother.cpp index cf9a1abc6..1ee858fad 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1315,6 +1315,13 @@ private: " strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void foo()\n" + "{\n" + " const std::string s(x());\n" + " strchr(s.c_str(), ',');\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); }