Fixed #4523 (false positive: (error) Possible null pointer dereference)
This commit is contained in:
parent
bc6d31c7c7
commit
fc42aa3a30
|
@ -857,7 +857,9 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
|
||||||
}
|
}
|
||||||
back = back->previous();
|
back = back->previous();
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok1->tokAt(-4), "%varid% = ( * %varid% )", varid)) {
|
} else if (Token::Match(tok1->tokAt(-4), "%varid% = ( * %varid%", varid)) {
|
||||||
|
reassign = true;
|
||||||
|
} else if (Token::Match(tok1->tokAt(-3), "%varid% = * %varid%", varid)) {
|
||||||
reassign = true;
|
reassign = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -701,6 +701,12 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(struct ABC *abc) {\n" // #4523
|
||||||
|
" abc = (*abc->ptr);\n"
|
||||||
|
" if (abc) { }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("int f(Item *item) {\n"
|
check("int f(Item *item) {\n"
|
||||||
" x = item ? ab(item->x) : 0;\n"
|
" x = item ? ab(item->x) : 0;\n"
|
||||||
" if (item) { }\n"
|
" if (item) { }\n"
|
||||||
|
|
Loading…
Reference in New Issue