Fixed #4523 (false positive: (error) Possible null pointer dereference)

This commit is contained in:
Daniel Marjamäki 2013-01-29 17:12:14 +01:00
parent 3679a809dd
commit 509dd9a989
2 changed files with 8 additions and 0 deletions

View File

@ -857,6 +857,8 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
}
back = back->previous();
}
} else if (Token::Match(tok1->tokAt(-4), "%varid% = ( * %varid% )", varid)) {
reassign = true;
}
if (reassign) {

View File

@ -695,6 +695,12 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(struct ABC *abc) {\n" // #4523
" abc = (*abc).next;\n"
" if (abc) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
check("int f(Item *item) {\n"
" x = item ? ab(item->x) : 0;\n"
" if (item) { }\n"