[PATCH v3 02/10] shell32/autocomplete: Handle heap_alloc failure
Gabriel Ivăncescu
gabrielopcode at gmail.com
Sat Sep 8 06:50:48 CDT 2018
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/shell32/autocomplete.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 39df45e..2f9d16f 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -209,10 +209,10 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0);
if (sel != -1) {
WCHAR *msg;
- int len;
+ UINT len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
- len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
- msg = heap_alloc((len + 1)*sizeof(WCHAR));
+ if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
+ return 0;
SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg));
@@ -319,7 +319,8 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
{
IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
WCHAR *msg;
- int sel, len;
+ UINT len;
+ INT sel;
switch (uMsg) {
case WM_MOUSEMOVE:
@@ -331,7 +332,8 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
if (sel < 0)
break;
len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
- msg = heap_alloc((len + 1)*sizeof(WCHAR));
+ if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
+ break;
SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg));
--
1.9.1
More information about the wine-devel
mailing list