Null pointers: Fixed false positive when sizeof without parentheses are used
This commit is contained in:
parent
4abee3a345
commit
e008a0508b
|
@ -896,7 +896,10 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// parameters to sizeof are not dereferenced
|
// parameters to sizeof are not dereferenced
|
||||||
if (Token::Match(tok2, "decltype|sizeof (")) {
|
if (Token::Match(tok2, "decltype|sizeof")) {
|
||||||
|
if (tok2->strAt(1) != "(")
|
||||||
|
break;
|
||||||
|
|
||||||
tok2 = tok2->next()->link();
|
tok2 = tok2->next()->link();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1434,6 +1434,13 @@ private:
|
||||||
" strcpy(a, s?b:c);\n"
|
" strcpy(a, s?b:c);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// sizeof
|
||||||
|
check("void f(struct fred_t *fred) {\n"
|
||||||
|
" if (!fred)\n"
|
||||||
|
" int sz = sizeof fred->x;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test CheckNullPointer::nullConstantDereference
|
// Test CheckNullPointer::nullConstantDereference
|
||||||
|
|
Loading…
Reference in New Issue