gdi32: Avoid reading bits outside of the glyph bitmap in GetGlyphOutline.
authorAlexandre Julliard <julliard@winehq.org>
Fri, 8 Apr 2011 10:38:32 +0000 (12:38 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 8 Apr 2011 11:03:22 +0000 (13:03 +0200)
dlls/gdi32/freetype.c

index aefb0e8d10ae71ae5c76d488ea9d8ddb4a6697b5..03a4cbd2635f0adfa7a22a4d4a90af1ce3d5203b 100644 (file)
@@ -4939,14 +4939,10 @@ DWORD WineEngGetGlyphOutline(GdiFont *incoming_font, UINT glyph, UINT format,
             BYTE *src = ft_face->glyph->bitmap.buffer, *dst = buf;
             INT h = ft_face->glyph->bitmap.rows;
             INT x;
+            memset( buf, 0, needed );
             while(h--) {
-                for(x = 0; x < pitch; x++)
-                {
-                    if(x < ft_face->glyph->bitmap.width)
-                        dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff : 0;
-                    else
-                        dst[x] = 0;
-                }
+                for(x = 0; x < pitch && x < ft_face->glyph->bitmap.width; x++)
+                    if (src[x / 8] & (1 << ( (7 - (x % 8))))) dst[x] = 0xff;
                 src += ft_face->glyph->bitmap.pitch;
                 dst += pitch;
             }
@@ -5025,9 +5021,10 @@ DWORD WineEngGetGlyphOutline(GdiFont *incoming_font, UINT glyph, UINT format,
             src = ft_face->glyph->bitmap.buffer;
             src_pitch = ft_face->glyph->bitmap.pitch;
 
+            height = min( height, ft_face->glyph->bitmap.rows );
             while ( height-- )
             {
-                for (x = 0; x < width; x++)
+                for (x = 0; x < width && x < ft_face->glyph->bitmap.width; x++)
                 {
                     if ( src[x / 8] & (1 << ( (7 - (x % 8)))) )
                         ((unsigned int *)dst)[x] = ~0u;