[PATCH] comctl32: process GetKeyState return correctly (Coverity)

Marcus Meissner marcus at jet.franken.de
Sun Apr 6 13:23:56 CDT 2014


1195663 Bad bit shift operation

0x8000 would mean selected.

HIWORD(x) does x>>16

it might work though, as the result is sign extended and so all upper
bits are 1s.

The common usage pattern is however &0x8000, so use that.

Ciao, Marcus
---
 dlls/comctl32/listview.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index bc9a04c..c5b5670 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -3677,8 +3677,8 @@ static void LISTVIEW_SetSelection(LISTVIEW_INFO *infoPtr, INT nItem)
 static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem, BOOL space)
 {
   /* FIXME: pass in the state */
-  WORD wShift = HIWORD(GetKeyState(VK_SHIFT));
-  WORD wCtrl = HIWORD(GetKeyState(VK_CONTROL));
+  WORD wShift = GetKeyState(VK_SHIFT) & 0x8000;
+  WORD wCtrl = GetKeyState(VK_CONTROL) & 0x8000;
   BOOL bResult = FALSE;
 
   TRACE("nItem=%d, wShift=%d, wCtrl=%d\n", nItem, wShift, wCtrl);
-- 
1.8.4.5




More information about the wine-patches mailing list