Fixed false positive in new stringLiteralWrite checker
This commit is contained in:
parent
6b80e61934
commit
e837bad01d
|
@ -35,7 +35,7 @@ namespace {
|
|||
void CheckString::stringLiteralWrite()
|
||||
{
|
||||
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (!tok->variable())
|
||||
if (!tok->variable() || !tok->variable()->isPointer())
|
||||
continue;
|
||||
const Token *str = tok->getValueTokenMinStrSize();
|
||||
if (!str)
|
||||
|
|
|
@ -111,8 +111,8 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:3]: (error) Modifying string literal directly or indirectly is undefined behaviour\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" char *abc = \"abc\";\n"
|
||||
" if (*abc == 'a'){}\n"
|
||||
" QString abc = \"abc\";\n"
|
||||
" abc[0] = 'a';\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue