Fixed #5472 (sizeof not handled as operator with respect to null pointer dereference)
This commit is contained in:
parent
fc24d491cc
commit
b5e023a46c
|
@ -409,6 +409,14 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Token::Match(tok2->previous(), "sizeof|.")) {
|
||||||
|
const Token *prev = tok2->previous();
|
||||||
|
while (Token::Match(prev,"%var%|.") && prev->str() != "sizeof")
|
||||||
|
prev = prev->previous();
|
||||||
|
if (Token::Match(prev,"sizeof"))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// assigned by subfunction?
|
// assigned by subfunction?
|
||||||
bool inconclusive = false;
|
bool inconclusive = false;
|
||||||
if (bailoutFunctionPar(tok2,val2.condition ? val2 : val, settings, &inconclusive)) {
|
if (bailoutFunctionPar(tok2,val2.condition ? val2 : val, settings, &inconclusive)) {
|
||||||
|
|
|
@ -374,6 +374,12 @@ private:
|
||||||
" if (x==63){}\n"
|
" if (x==63){}\n"
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 2U, 63));
|
ASSERT_EQUALS(false, testValueOfX(code, 2U, 63));
|
||||||
|
|
||||||
|
code = "void f(int *x) {\n"
|
||||||
|
" char a[sizeof x.y];\n"
|
||||||
|
" if (x==0){}\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(false, testValueOfX(code, 2U, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowBeforeConditionIfElse() { // bailout: if/else/etc
|
void valueFlowBeforeConditionIfElse() { // bailout: if/else/etc
|
||||||
|
|
Loading…
Reference in New Issue