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

This commit is contained in:
Daniel Marjamäki 2013-01-30 16:52:12 +01:00
parent bc6d31c7c7
commit fc42aa3a30
2 changed files with 9 additions and 1 deletions

View File

@ -857,7 +857,9 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
}
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;
}

View File

@ -701,6 +701,12 @@ private:
"}");
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"
" x = item ? ab(item->x) : 0;\n"
" if (item) { }\n"