Fixed #7659 (crash: Token::varId() : vxl: brdb_selection.cxx)

This commit is contained in:
Daniel Marjamäki 2016-08-06 18:07:41 +02:00
parent 3e509fb561
commit a8df08f22b
2 changed files with 20 additions and 1 deletions

View File

@ -168,7 +168,9 @@ void CheckStl::iterators()
// inserting iterator range.. // inserting iterator range..
if (tok2->strAt(2) == "insert") { if (tok2->strAt(2) == "insert") {
const Token *par2 = itTok->nextArgument(); const Token *par2 = itTok->nextArgument();
while (par2 && par2->str() != ")") { if (!par2 || par2->nextArgument())
continue;
while (par2->str() != ")") {
if (par2->varId() == container->declarationId()) if (par2->varId() == container->declarationId())
break; break;
if (par2->str() == "(") if (par2->str() == "(")

View File

@ -209,6 +209,23 @@ private:
" l2.insert(it, l1.end());\n" " l2.insert(it, l1.end());\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// only warn for insert when there are preciself 2 arguments.
check("void foo() {\n"
" list<int> l1;\n"
" list<int> l2;\n"
" list<int>::iterator it = l1.begin();\n"
" l2.insert(it);\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void foo() {\n"
" list<int> l1;\n"
" list<int> l2;\n"
" list<int>::iterator it = l1.begin();\n"
" l2.insert(it,0,1);\n"
"}");
ASSERT_EQUALS("", errout.str());
} }
void iterator4() { void iterator4() {