Akihiro Sagawa : gdi32: Return GDI_ERROR when requested empty glyph bitmaps .
Alexandre Julliard
julliard at winehq.org
Thu Sep 26 15:44:06 CDT 2013
Module: wine
Branch: master
Commit: e2bce62a6daf5e79e5add26920552f3ef5df8170
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e2bce62a6daf5e79e5add26920552f3ef5df8170
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Thu Sep 26 00:47:59 2013 +0900
gdi32: Return GDI_ERROR when requested empty glyph bitmaps.
---
dlls/gdi32/freetype.c | 23 ++++++++++++++---------
dlls/gdi32/tests/font.c | 2 +-
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 2a2619ee..bd4c895 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -6518,12 +6518,14 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
}
}
- lpgm->gmBlackBoxX = (right - left) >> 6;
- lpgm->gmBlackBoxY = (top - bottom) >> 6;
+ width = (right - left) >> 6;
+ height = (top - bottom) >> 6;
+ lpgm->gmBlackBoxX = width;
+ lpgm->gmBlackBoxY = height;
lpgm->gmptGlyphOrigin.x = origin_x >> 6;
lpgm->gmptGlyphOrigin.y = origin_y >> 6;
abc->abcA = left >> 6;
- abc->abcB = (right - left) >> 6;
+ abc->abcB = width;
abc->abcC = adv - abc->abcA - abc->abcB;
TRACE("%u,%u,%s,%d,%d\n", lpgm->gmBlackBoxX, lpgm->gmBlackBoxY,
@@ -6552,12 +6554,11 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
switch(format) {
case GGO_BITMAP:
- width = lpgm->gmBlackBoxX;
- height = lpgm->gmBlackBoxY;
pitch = ((width + 31) >> 5) << 2;
needed = pitch * height;
if(!buf || !buflen) break;
+ if (!needed) return GDI_ERROR; /* empty glyph */
switch(ft_face->glyph->format) {
case ft_glyph_format_bitmap:
@@ -6604,12 +6605,11 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
unsigned int max_level, row, col;
BYTE *start, *ptr;
- width = lpgm->gmBlackBoxX;
- height = lpgm->gmBlackBoxY;
pitch = (width + 3) / 4 * 4;
needed = pitch * height;
if(!buf || !buflen) break;
+ if (!needed) return GDI_ERROR; /* empty glyph */
max_level = get_max_level( format );
@@ -6677,12 +6677,11 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
BYTE *src, *dst;
INT src_pitch, x;
- width = lpgm->gmBlackBoxX;
- height = lpgm->gmBlackBoxY;
pitch = width * 4;
needed = pitch * height;
if (!buf || !buflen) break;
+ if (!needed) return GDI_ERROR; /* empty glyph */
memset(buf, 0, buflen);
dst = buf;
@@ -6716,6 +6715,12 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
(format == WINE_GGO_HRGB_BITMAP || format == WINE_GGO_HBGR_BITMAP)?
FT_RENDER_MODE_LCD: FT_RENDER_MODE_LCD_V;
+ if (!width || !height)
+ {
+ if (!buf || !buflen) return 0;
+ return GDI_ERROR;
+ }
+
if ( lcdfilter == FT_LCD_FILTER_DEFAULT || lcdfilter == FT_LCD_FILTER_LIGHT )
{
if ( render_mode == FT_RENDER_MODE_LCD)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index f68021e..eed9cec 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -4169,7 +4169,7 @@ static void test_GetGlyphOutline(void)
}
}
else
- todo_wine ok(ret == GDI_ERROR, "%2d:GetGlyphOutlineW should return GDI_ERROR, got %d\n", fmt[i], ret);
+ ok(ret == GDI_ERROR, "%2d:GetGlyphOutlineW should return GDI_ERROR, got %d\n", fmt[i], ret);
}
}
More information about the wine-cvs
mailing list