Nikolay Sivov : dwrite: Properly truncate face name to LOGFONT size.
Alexandre Julliard
julliard at winehq.org
Tue May 22 15:37:14 CDT 2018
Module: wine
Branch: master
Commit: e5966d747543ebe2bc4270c424f16f50e9972524
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e5966d747543ebe2bc4270c424f16f50e9972524
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue May 22 11:50:43 2018 +0300
dwrite: Properly truncate face name to LOGFONT size.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dwrite/opentype.c | 15 +++++++++++++--
dlls/dwrite/tests/font.c | 9 +++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index b95083e..db44368 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -1736,8 +1736,19 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR *
if (!exists)
IDWriteLocalizedStrings_FindLocaleName(lfnames, enusW, &index, &exists);
- if (exists)
- IDWriteLocalizedStrings_GetString(lfnames, index, lfname, LF_FACESIZE);
+ if (exists) {
+ UINT32 length = 0;
+ WCHAR *nameW;
+
+ IDWriteLocalizedStrings_GetStringLength(lfnames, index, &length);
+ nameW = heap_alloc((length + 1) * sizeof(WCHAR));
+ if (nameW) {
+ *nameW = 0;
+ IDWriteLocalizedStrings_GetString(lfnames, index, nameW, length + 1);
+ lstrcpynW(lfname, nameW, LF_FACESIZE);
+ heap_free(nameW);
+ }
+ }
IDWriteLocalizedStrings_Release(lfnames);
}
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index db9949f..f23bfcc 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -2515,6 +2515,7 @@ static void get_logfont_from_font(IDWriteFont *font, LOGFONTW *logfont)
if (exists) {
static const WCHAR enusW[] = {'e','n','-','u','s',0};
WCHAR localeW[LOCALE_NAME_MAX_LENGTH];
+ WCHAR nameW[256];
UINT32 index;
/* Fallback to en-us if there's no string for user locale. */
@@ -2525,8 +2526,12 @@ static void get_logfont_from_font(IDWriteFont *font, LOGFONTW *logfont)
if (!exists)
IDWriteLocalizedStrings_FindLocaleName(names, enusW, &index, &exists);
- if (exists)
- IDWriteLocalizedStrings_GetString(names, index, logfont->lfFaceName, ARRAY_SIZE(logfont->lfFaceName));
+ if (exists) {
+ nameW[0] = 0;
+ hr = IDWriteLocalizedStrings_GetString(names, index, nameW, ARRAY_SIZE(nameW));
+ ok(hr == S_OK, "Failed to get name string, hr %#x.\n", hr);
+ lstrcpynW(logfont->lfFaceName, nameW, ARRAY_SIZE(logfont->lfFaceName));
+ }
}
IDWriteLocalizedStrings_Release(names);
More information about the wine-cvs
mailing list