usp10: Check that there are sufficient script_items before setting the last pointer.
This commit is contained in:
parent
6c0e61cd65
commit
b367e902c9
|
@ -673,6 +673,7 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
|
||||||
WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
|
WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
|
||||||
WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
|
WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
|
||||||
WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
|
WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
|
||||||
|
WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
|
||||||
|
|
||||||
SCRIPT_CACHE psc;
|
SCRIPT_CACHE psc;
|
||||||
int cChars;
|
int cChars;
|
||||||
|
@ -848,6 +849,15 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
|
||||||
ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
|
ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
|
||||||
ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
|
ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
|
||||||
pItem[0].a.s.uBidiLevel);
|
pItem[0].a.s.uBidiLevel);
|
||||||
|
|
||||||
|
/* This test checks to make sure that the test to see if there are sufficient buffers to store *
|
||||||
|
* the pointer to the last char works. Note that windows often needs a greater number of *
|
||||||
|
* SCRIPT_ITEMS to process a string than is returned in pcItems. */
|
||||||
|
cInChars = (sizeof(TestItem6)/2)-1;
|
||||||
|
cMaxItems = 4;
|
||||||
|
hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
|
||||||
|
ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
|
static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
|
||||||
|
|
|
@ -669,16 +669,17 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
|
||||||
/* While not strictly necessary according to the spec, make sure the n+1
|
/* While not strictly necessary according to the spec, make sure the n+1
|
||||||
* item is set up to prevent random behaviour if the caller erroneously
|
* item is set up to prevent random behaviour if the caller erroneously
|
||||||
* checks the n+1 structure */
|
* checks the n+1 structure */
|
||||||
memset(&pItems[index+1].a, 0, sizeof(SCRIPT_ANALYSIS));
|
index++;
|
||||||
|
memset(&pItems[index].a, 0, sizeof(SCRIPT_ANALYSIS));
|
||||||
|
|
||||||
TRACE("index=%d cnt=%d iCharPos=%d\n", index+1, cnt, pItems[index+1].iCharPos);
|
TRACE("index=%d cnt=%d iCharPos=%d\n", index, cnt, pItems[index].iCharPos);
|
||||||
|
|
||||||
/* Set one SCRIPT_STATE item being returned */
|
/* Set one SCRIPT_STATE item being returned */
|
||||||
if (pcItems) *pcItems = index + 1;
|
if (index + 1 > cMaxItems) return E_OUTOFMEMORY;
|
||||||
|
if (pcItems) *pcItems = index;
|
||||||
|
|
||||||
/* Set SCRIPT_ITEM */
|
/* Set SCRIPT_ITEM */
|
||||||
pItems[index+1].iCharPos = cnt; /* the last + 1 item
|
pItems[index].iCharPos = cnt; /* the last item contains the ptr to the lastchar */
|
||||||
contains the ptr to the lastchar */
|
|
||||||
heap_free(levels);
|
heap_free(levels);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue