Commit 09802e2c authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Handle negative position given to EM_POSFROMCHAR.

parent 795c4a77
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment