[PATCH 2/2] comctl32/edit: Avoid division by zero in EDIT_EM_LineScroll_internal.
Roman Pišl
rpisl at seznam.cz
Sat Apr 18 06:09:19 CDT 2020
Signed-off-by: Roman Pišl <rpisl at seznam.cz>
---
dlls/comctl32/edit.c | 8 ++++++--
dlls/comctl32/tests/edit.c | 4 ++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c
index b0c32445b0..4861fd7a9c 100644
--- a/dlls/comctl32/edit.c
+++ b/dlls/comctl32/edit.c
@@ -1579,8 +1579,12 @@ static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
{
INT nyoff;
INT x_offset_in_pixels;
- INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
- es->line_height;
+ INT lines_per_page;
+
+ if (!es->line_height || !es->char_width)
+ return TRUE;
+
+ lines_per_page = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
if (es->style & ES_MULTILINE)
{
diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c
index a32d9dec86..a632fc93c9 100644
--- a/dlls/comctl32/tests/edit.c
+++ b/dlls/comctl32/tests/edit.c
@@ -1790,6 +1790,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam,
ok(r == 1, "Returned %x, expected 1.\n", r);
r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010);
todo_wine ok(r == 1, "Returned %x, expected 1.\n", r);
+ r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1);
+ ok(r == 1, "Returned %x, expected 1.\n", r);
return result;
@@ -1800,6 +1802,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam,
ok(r == 1, "Returned %x, expected 1.\n", r);
r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010);
todo_wine ok(r == 1, "Returned %x, expected 1.\n", r);
+ r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1);
+ ok(r == 1, "Returned %x, expected 1.\n", r);
break;
}
--
2.20.1
More information about the wine-devel
mailing list