Fixed #2301 (false positive: The given size 3 is mismatching)
This commit is contained in:
parent
2d97189486
commit
49ee1533d9
|
@ -2444,7 +2444,7 @@ void CheckMemoryLeakInFunction::parseFunctionScope(const Token *tok, const Token
|
||||||
{
|
{
|
||||||
const std::string varname(tok2->strAt(3));
|
const std::string varname(tok2->strAt(3));
|
||||||
const unsigned int varid = tok2->tokAt(3)->varId();
|
const unsigned int varid = tok2->tokAt(3)->varId();
|
||||||
const unsigned int sz = _tokenizer->sizeOfType(tok->next());
|
const unsigned int sz = _tokenizer->sizeOfType(tok2->next());
|
||||||
checkScope(tok->next(), varname, varid, classmember, sz);
|
checkScope(tok->next(), varname, varid, classmember, sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,8 @@ private:
|
||||||
TEST_CASE(mismatch3);
|
TEST_CASE(mismatch3);
|
||||||
TEST_CASE(mismatch4);
|
TEST_CASE(mismatch4);
|
||||||
|
|
||||||
|
TEST_CASE(mismatchSize);
|
||||||
|
|
||||||
TEST_CASE(func3);
|
TEST_CASE(func3);
|
||||||
TEST_CASE(func4);
|
TEST_CASE(func4);
|
||||||
TEST_CASE(func5);
|
TEST_CASE(func5);
|
||||||
|
@ -1359,7 +1361,17 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Mismatching allocation and deallocation: p\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Mismatching allocation and deallocation: p\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mismatchSize()
|
||||||
|
{
|
||||||
|
check("void f(char *buf)\n"
|
||||||
|
"{\n"
|
||||||
|
" int i;\n"
|
||||||
|
" buf = malloc(3);\n"
|
||||||
|
" buf[i] = 0;\n"
|
||||||
|
" free(buf);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue