Dylan Smith : richedit: Handle negative position given to EM_POSFROMCHAR.
Alexandre Julliard
julliard at winehq.org
Wed Oct 29 09:39:17 CDT 2008
Module: wine
Branch: master
Commit: 09802e2c764847ecccd2c82d891d887b97982baf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=09802e2c764847ecccd2c82d891d887b97982baf
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Tue Oct 28 18:16:23 2008 -0400
richedit: Handle negative position given to EM_POSFROMCHAR.
---
dlls/riched20/editor.c | 1 +
dlls/riched20/tests/editor.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index e35e3cb..ce754b9 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3544,6 +3544,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
nCharOfs = lParam;
nLength = ME_GetTextLength(editor);
nCharOfs = min(nCharOfs, nLength);
+ nCharOfs = max(nCharOfs, 0);
ME_RunOfsFromCharOfs(editor, nCharOfs, &pRun, &nOffset);
assert(pRun->type == diRun);
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 2c803ae..7748d92 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -649,6 +649,10 @@ static void test_EM_POSFROMCHAR(void)
SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)+1);
ok(pt.x == xpos, "pt.x = %d\n", pt.x);
+ /* Try a negative position. */
+ SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, -1);
+ ok(pt.x == 1, "pt.x = %d\n", pt.x);
+
DestroyWindow(hwndRichEdit);
}
More information about the wine-cvs
mailing list