Fix #132 (False positive returning memcpy())

This commit is contained in:
Reijo Tomperi 2009-03-03 20:39:17 +00:00
parent 69c23301db
commit 832275bc37
2 changed files with 11 additions and 2 deletions

View File

@ -625,7 +625,7 @@ Token *CheckMemoryLeakClass::getcode(const Token *tok, std::list<const Token *>
}
}
}
else if (Token::Match(tok, ("return strcpy|strncpy ( " + varnameStr).c_str()))
else if (Token::Match(tok, ("return strcpy|strncpy|memcpy ( " + varnameStr).c_str()))
{
addtoken("use");
tok = tok->tokAt(2);

View File

@ -122,6 +122,7 @@ private:
TEST_CASE(ret4);
TEST_CASE(ret5); // Bug 2458436 - return use
TEST_CASE(ret6);
TEST_CASE(ret7);
TEST_CASE(mismatch1);
TEST_CASE(mismatch2);
@ -1016,7 +1017,15 @@ private:
ASSERT_EQUALS(std::string(""), errout.str());
}
void ret7()
{
check("void foo()\n"
"{\n"
" char *c = new char[50];\n"
" return memcpy(c, \"foo\",4);\n"
"}\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
void mismatch1()