From: Haoyang Chen chenhaoyang@kylinos.cn
--- dlls/mlang/mlang.c | 3 +++ dlls/mlang/tests/mlang.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c index 9f7d1159e57..3ff3c8b34bb 100644 --- a/dlls/mlang/mlang.c +++ b/dlls/mlang/mlang.c @@ -3471,7 +3471,10 @@ static HRESULT WINAPI fnIMLangFontLink2_GetFontCodePages(IMLangFontLink2 *iface,
TRACE("(%p)->(%p %p %p)\n", This, hdc, hfont, codepages);
+ if (codepages) *codepages = 0; + old_font = SelectObject(hdc, hfont); + if (!old_font) return E_FAIL; GetTextCharsetInfo(hdc, &fontsig, 0); SelectObject(hdc, old_font);
diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c index 42847406eb8..83caaf163a6 100644 --- a/dlls/mlang/tests/mlang.c +++ b/dlls/mlang/tests/mlang.c @@ -2809,6 +2809,24 @@ static void test_MapFont(IMLangFontLink *font_link, IMLangFontLink2 *font_link2) ok((codepages & (~font_codepages)) != 0 && (codepages & font_codepages) != 0, "code pages of font is incorrect\n");
+ font_codepages = 1; + ret = IMLangFontLink_GetFontCodePages(font_link, NULL, font1, &font_codepages); + ok(ret == E_FAIL && !font_codepages, "expected E_FAIL, but got: %lx, font_codepages:%lx \n", + ret, font_codepages); + font_codepages = 2; + ret = IMLangFontLink_GetFontCodePages(font_link, hdc, NULL, &font_codepages); + ok(ret == E_FAIL && !font_codepages, "expected E_FAIL, but got: %lx, font_codepages:%lx \n", + ret, font_codepages); + + font_codepages = 3; + ret = IMLangFontLink_GetFontCodePages(font_link, (void*)0xabc, font1, &font_codepages); + ok(ret == E_FAIL && !font_codepages, "expected E_FAIL, but got: %lx, font_codepages:%lx \n", + ret, font_codepages); + font_codepages = 4; + ret = IMLangFontLink_GetFontCodePages(font_link, hdc, (void*)0x123456, &font_codepages); + ok(ret == E_FAIL && !font_codepages, "expected E_FAIL, but got: %lx, font_codepages:%lx \n", + ret, font_codepages); + IMLangFontLink_ResetFontMapping(font_link); IMLangFontLink2_ResetFontMapping(font_link2); ReleaseDC(NULL, hdc);