https://bugs.winehq.org/show_bug.cgi?id=37483
Bug ID: 37483 Summary: Possible null pointer dereference: lpItem - otherwise it is redundant to check it (Cppcheck) Product: Wine Version: 1.7.29 Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P2 Component: comctl32 Assignee: wine-bugs@winehq.org Reporter: 00cpxxx@gmail.com Distribution: ---
[dlls\comctl32\listview.c:4222] -> [dlls\comctl32\listview.c:4247]: (warning) Possible null pointer dereference: lpItem - otherwise it is redundant to check it
lpItem may be null but later it's used without check:
4193 if (infoPtr->dwStyle & LVS_OWNERDATA) 4194 { 4195 /* a virtual listview only stores selection and focus */ 4196 if (lpLVItem->mask & ~LVIF_STATE) 4197 return FALSE; 4198 lpItem = NULL; 4199 }
...
4222 if ((lpLVItem->mask & LVIF_IMAGE) && (lpItem->hdr.iImage != lpLVItem->iImage)) 4223 uChanged |= LVIF_IMAGE; 4224 4225 if ((lpLVItem->mask & LVIF_PARAM) && (lpItem->lParam != lpLVItem->lParam)) 4226 uChanged |= LVIF_PARAM;
https://bugs.winehq.org/show_bug.cgi?id=37483
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- Hi, Bruno.
I don't see a problem with this. The idea here:
--- if (infoPtr->dwStyle & LVS_OWNERDATA) { /* a virtual listview only stores selection and focus */ if (lpLVItem->mask & ~LVIF_STATE) return FALSE; lpItem = NULL; } ---
is to return if any mask bit but LVIF_STATE is set. So lpItem is only NULL when lpLVItem->mask == LVIF_STATE. Later mask is always tested before accessing lpItem. I'll keep this open waiting for your reply, but I think there's no bug.
https://bugs.winehq.org/show_bug.cgi?id=37483
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID
--- Comment #2 from Bruno Jesus 00cpxxx@gmail.com --- I see, thanks for the explanation, I guess that logic is too hard for the static analyzer to follow.
https://bugs.winehq.org/show_bug.cgi?id=37483
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #3 from Bruno Jesus 00cpxxx@gmail.com --- Closing invalid bugs.