Roman Pišl : user32/edit: Avoid division by zero in EDIT_EM_LineScroll_internal.
Alexandre Julliard
julliard at winehq.org
Mon Apr 20 15:48:20 CDT 2020
Module: wine
Branch: master
Commit: f04d8a270e903a4772cdc39107a5aba5d1cb32ef
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f04d8a270e903a4772cdc39107a5aba5d1cb32ef
Author: Roman Pišl <rpisl at seznam.cz>
Date: Mon Apr 20 12:20:15 2020 +0200
user32/edit: Avoid division by zero in EDIT_EM_LineScroll_internal.
Signed-off-by: Roman Pišl <rpisl at seznam.cz>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/edit.c | 8 ++++++--
dlls/user32/tests/edit.c | 4 ++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index aba6a084a2..683c2faea3 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -1674,8 +1674,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/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 2289bbf03f..34bb1e5a76 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -1765,6 +1765,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam,
ok(r == 1, "Returned %ld, expected 1.\n", r);
r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010);
todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r);
+ r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1);
+ ok(r == 1, "Returned %ld, expected 1.\n", r);
return result;
@@ -1775,6 +1777,8 @@ static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam,
ok(r == 1, "Returned %ld, expected 1.\n", r);
r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010);
todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r);
+ r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1);
+ ok(r == 1, "Returned %ld, expected 1.\n", r);
break;
}
More information about the wine-cvs
mailing list