From 7547757892c3543354dd2b8e6de5f5a055c7ad1b Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Fri, 2 Aug 2019 20:28:30 +0900 Subject: [PATCH] [WIN32SS][NTGDI] Improve IntGetOutlineTextMetrics (#1760) Improve size checking of IntGetOutlineTextMetrics function. --- win32ss/gdi/ntgdi/freetype.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index 37ff3fbf5a7..d31178d3f2e 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -2304,22 +2304,30 @@ IntGetOutlineTextMetrics(PFONTGDI FontGDI, Cache = &SharedFace->UserLanguage; } - if (Cache->OutlineRequiredSize && Size < Cache->OutlineRequiredSize) + if (Size == 0 && Cache->OutlineRequiredSize > 0) { + ASSERT(Otm == NULL); return Cache->OutlineRequiredSize; } IntInitFontNames(&FontNames, SharedFace); + Cache->OutlineRequiredSize = FontNames.OtmSize; - if (!Cache->OutlineRequiredSize) + if (Size == 0) { - Cache->OutlineRequiredSize = FontNames.OtmSize; + ASSERT(Otm == NULL); + IntFreeFontNames(&FontNames); + return Cache->OutlineRequiredSize; } + ASSERT(Otm != NULL); + if (Size < Cache->OutlineRequiredSize) { + DPRINT1("Size %u < OutlineRequiredSize %u\n", Size, + Cache->OutlineRequiredSize); IntFreeFontNames(&FontNames); - return Cache->OutlineRequiredSize; + return 0; /* failure */ } XScale = Face->size->metrics.x_scale;