From 4f01bee4c81f9cbee4b854f47dcccbcda6ca396d Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 19 Jul 2016 23:03:01 +0300 Subject: [PATCH] dwrite: Filter invalid weight in SetFontWeight(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/layout.c | 3 +++ dlls/dwrite/tests/layout.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index 22c3f310403..6f10ce47324 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -2889,6 +2889,9 @@ static HRESULT WINAPI dwritetextlayout_SetFontWeight(IDWriteTextLayout3 *iface, TRACE("(%p)->(%d %s)\n", This, weight, debugstr_range(&range)); + if ((UINT32)weight > DWRITE_FONT_WEIGHT_ULTRA_BLACK) + return E_INVALIDARG; + value.range = range; value.u.weight = weight; return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_WEIGHT, &value); diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 9f3b8c31a79..4134a976d52 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -1249,6 +1249,11 @@ static void test_fontweight(void) ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight); ok(range.length == 6, "got %d\n", range.length); + range.startPosition = 0; + range.length = 6; + hr = IDWriteTextLayout_SetFontWeight(layout, 1000, range); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + size = IDWriteTextLayout_GetMaxWidth(layout); ok(size == 100.0, "got %.2f\n", size); -- 2.11.4.GIT