Module: wine Branch: master Commit: 2dd903885becd74264393007a5e8c4e47c52c5e8 URL: https://gitlab.winehq.org/wine/wine/-/commit/2dd903885becd74264393007a5e8c4e...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Aug 3 13:41:35 2022 +0300
dwrite: Fix stretch value validation in CreateTextFormat().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
---
dlls/dwrite/format.c | 11 +++++++---- dlls/dwrite/tests/layout.c | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/dwrite/format.c b/dlls/dwrite/format.c index dd120fe032e..01a6dfd06c9 100644 --- a/dlls/dwrite/format.c +++ b/dlls/dwrite/format.c @@ -1,5 +1,5 @@ /* - * Copyright 2012, 2014-2021 Nikolay Sivov for CodeWeavers + * Copyright 2012, 2014-2022 Nikolay Sivov for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -723,10 +723,13 @@ HRESULT create_text_format(const WCHAR *family_name, IDWriteFontCollection *coll if (size <= 0.0f) return E_INVALIDARG;
- if (((UINT32)weight > DWRITE_FONT_WEIGHT_ULTRA_BLACK) || - ((UINT32)stretch > DWRITE_FONT_STRETCH_ULTRA_EXPANDED) || - ((UINT32)style > DWRITE_FONT_STYLE_ITALIC)) + if ((UINT32)weight > DWRITE_FONT_WEIGHT_ULTRA_BLACK + || stretch == DWRITE_FONT_STRETCH_UNDEFINED + || (UINT32)stretch > DWRITE_FONT_STRETCH_ULTRA_EXPANDED + || (UINT32)style > DWRITE_FONT_STYLE_ITALIC) + { return E_INVALIDARG; + }
if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY; diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 5e7e1b16d27..3b2289b40ce 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -1196,6 +1196,10 @@ static void test_CreateTextFormat(void) 10, 10.0f, L"en-us", &format); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+ hr = IDWriteFactory_CreateTextFormat(factory, L"Tahoma", NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_ITALIC, + DWRITE_FONT_STRETCH_UNDEFINED, 10.0f, L"en-us", &format); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + /* empty family name */ hr = IDWriteFactory_CreateTextFormat(factory, L"", NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 10.0f, L"en-us", &format);