Mikołaj Zalewski : shell32: autocomplete: Don' t use sel uninitialized.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 27 06:58:40 CDT 2007


Module: wine
Branch: master
Commit: 3924e6b730850a5f42c5d907ea7c85565e013212
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3924e6b730850a5f42c5d907ea7c85565e013212

Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date:   Tue Mar 20 23:04:36 2007 +0100

shell32: autocomplete: Don't use sel uninitialized.

---

 dlls/shell32/autocomplete.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 2ffe0d6..ed32f44 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -624,7 +624,7 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
 {
     IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
     WCHAR *msg;
-    int sel = -1, len;
+    int sel, len;
 
     switch (uMsg) {
 	case WM_MOUSEMOVE:
@@ -632,9 +632,11 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
 	    SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0);
 	    break;
 	case WM_LBUTTONDOWN:
-	    len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL);
+	    sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
+	    if (sel < 0)
+		break;
+	    len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
 	    msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR));
-	    sel = (INT)SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
 	    SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
 	    SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
 	    SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg));




More information about the wine-cvs mailing list