mirror of
https://github.com/reactos/reactos.git
synced 2024-11-26 21:13:30 +08:00
[RICHED20] Fix assert in editpad due to excessive tab count (#6976)
* https://jira.reactos.org/browse/CORE-8452
* Cherry pick this Wine commit into ReactOS:
7b2ff97773
This commit is contained in:
parent
ecb5cae48f
commit
40955b447c
@ -494,8 +494,8 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_Paragraph *para, const PA
|
||||
COPY_FIELD(PFM_ALIGNMENT, wAlignment);
|
||||
if (dwMask & PFM_TABSTOPS)
|
||||
{
|
||||
para->fmt.cTabCount = pFmt->cTabCount;
|
||||
memcpy(para->fmt.rgxTabs, pFmt->rgxTabs, pFmt->cTabCount*sizeof(LONG));
|
||||
para->fmt.cTabCount = max(0, min(pFmt->cTabCount, MAX_TAB_STOPS)); /* Clamp between 0 and MAX_TAB_STOPS */
|
||||
memcpy(para->fmt.rgxTabs, pFmt->rgxTabs, para->fmt.cTabCount*sizeof(LONG));
|
||||
}
|
||||
|
||||
#define EFFECTS_MASK (PFM_RTLPARA|PFM_KEEP|PFM_KEEPNEXT|PFM_PAGEBREAKBEFORE| \
|
||||
|
@ -8642,6 +8642,35 @@ static void test_alignment_style(void)
|
||||
SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.wAlignment == align_mask[i], "got %d expect %d\n", pf.wAlignment, align_mask[i]);
|
||||
|
||||
/* Test out of bounds tab count */
|
||||
pf.dwMask = PFM_TABSTOPS;
|
||||
pf.cTabCount = -25000;
|
||||
SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == -25000, "Got %d\n", pf.cTabCount);
|
||||
SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == 0, "Got %d\n", pf.cTabCount);
|
||||
pf.dwMask = PFM_TABSTOPS;
|
||||
pf.cTabCount = 25000;
|
||||
SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == 25000, "Got %d\n", pf.cTabCount);
|
||||
SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == 32, "Got %d\n", pf.cTabCount);
|
||||
pf.dwMask = PFM_TABSTOPS;
|
||||
pf.cTabCount = 32;
|
||||
SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == 32, "Got %d\n", pf.cTabCount);
|
||||
pf.dwMask = PFM_TABSTOPS;
|
||||
pf.cTabCount = 33;
|
||||
SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == 32, "Got %d\n", pf.cTabCount);
|
||||
pf.dwMask = PFM_TABSTOPS;
|
||||
pf.cTabCount = 1;
|
||||
SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
|
||||
ok(pf.cTabCount == 1, "Got %d\n", pf.cTabCount);
|
||||
|
||||
DestroyWindow(richedit);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user