From 5bb7590fadcba0d308870ddfa58fc43739a32112 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Mon, 19 Mar 2012 13:48:39 -0500 Subject: [PATCH] usp10: Properly handle invalid arguments to ScriptBreak. --- dlls/usp10/tests/usp10.c | 13 +++++++++++++ dlls/usp10/usp10.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index 82297558030..0b5033bd857 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -2798,6 +2798,19 @@ static void test_ScriptBreak(void) hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL); ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr); + /* + * This Test crashes pre Vista. + + hr = ScriptBreak(test, 1, &items[0].a, NULL); + ok(hr == E_INVALIDARG, "ScriptBreak should return E_INVALIDARG not %08x\n", hr); + */ + + hr = ScriptBreak(test, 0, &items[0].a, &la); + ok(hr == E_FAIL || broken(hr == S_OK), "ScriptBreak should return E_FAIL not %08x\n", hr); + + hr = ScriptBreak(test, -1, &items[0].a, &la); + ok(hr == E_INVALIDARG || broken(hr == S_OK), "ScriptBreak should return E_INVALIDARG not %08x\n", hr); + memset(&la, 0, sizeof(la)); hr = ScriptBreak(test, 1, &items[0].a, &la); ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr); diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index cad234f3873..4d0d9f30ff8 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -2665,7 +2665,8 @@ HRESULT WINAPI ScriptBreak(const WCHAR *chars, int count, const SCRIPT_ANALYSIS { TRACE("(%s, %d, %p, %p)\n", debugstr_wn(chars, count), count, sa, la); - if (!la) return S_FALSE; + if (count < 0 || !la) return E_INVALIDARG; + if (count == 0) return E_FAIL; BREAK_line(chars, count, sa, la);