diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 9fc1dfca3..b2aee23f6 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1058,7 +1058,8 @@ void CheckUninitVar::checkScope(const Scope* scope) if (tok->isStandardType()) stdtype = true; } - + while (tok && tok->str() != ";") + tok = tok->next(); if (stdtype || i->isPointer()) checkScopeForVariable(tok, *i, NULL); } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 66be4ca34..88a427ca7 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2158,6 +2158,12 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + // Ticket #3906 - False positive for std::vector pointer + checkUninitVar2("void f() {\n" + " std::vector *x = NULL;\n" + " return x;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } // #3869 - reference variable