Author: spouliot
Date: 2006-06-28 15:39:27 -0400 (Wed, 28 Jun 2006)
New Revision: 62126

Modified:
   trunk/libgdiplus/src/ChangeLog
   trunk/libgdiplus/src/font.c
Log:
2006-06-28  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * font.c: Make sure GdipGetLogFont[A|W] always initialize the LOGFONT
        structure correctly - even if it must return an error. Fix #78721.



Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog      2006-06-28 19:35:18 UTC (rev 62125)
+++ trunk/libgdiplus/src/ChangeLog      2006-06-28 19:39:27 UTC (rev 62126)
@@ -1,3 +1,8 @@
+2006-06-28  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * font.c: Make sure GdipGetLogFont[A|W] always initialize the LOGFONT
+       structure correctly - even if it must return an error. Fix #78721.
+
 2006-06-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * bitmap.c: avoid invalid read when we have a 24bpp format.

Modified: trunk/libgdiplus/src/font.c
===================================================================
--- trunk/libgdiplus/src/font.c 2006-06-28 19:35:18 UTC (rev 62125)
+++ trunk/libgdiplus/src/font.c 2006-06-28 19:39:27 UTC (rev 62126)
@@ -811,13 +811,24 @@
        return(NotImplemented);
 }
 
-static void
+static GpStatus
 gdip_logfont_from_font(GpFont *font, GpGraphics *graphics, void *lf, bool ucs2)
 {
        LOGFONTA                *logFont;
 
+       if (!lf)
+               return InvalidParameter;
+
        logFont = (LOGFONTA *)lf;
 
+       if (!font) {
+               /* lf is an Out parameter and must be initialized if 
+                  not NULL (even on error) */
+               memset (logFont, 0, ucs2 ? sizeof (LOGFONTW) : sizeof 
(LOGFONTA));
+               logFont->lfCharSet = 1; // DEFAULT_CHARSET
+               return InvalidParameter;
+       }
+
        logFont->lfHeight = -(font->sizeInPixels);
        logFont->lfWidth = 0;
        logFont->lfEscapement = 0;      // FIXME
@@ -881,6 +892,7 @@
                memset (logFont->lfFaceName, 0, LF_FACESIZE);
                memcpy (logFont->lfFaceName, font->face, len < LF_FACESIZE ? 
len : LF_FACESIZE - 1);
        }
+       return Ok;
 }
 
 GpStatus
@@ -930,31 +942,19 @@
 
        *font = result;
 
-       gdip_logfont_from_font(result, NULL, lf, FALSE);
-
-       return Ok;
+       return gdip_logfont_from_font (result, NULL, lf, FALSE);
 }
 
 GpStatus
 GdipGetLogFontW(GpFont *font, GpGraphics *graphics, void *lf)
 {
-       if (!font || !lf) {
-               return(InvalidParameter);
-       }
-       gdip_logfont_from_font(font, graphics, lf, TRUE);
-       return Ok;
+       return gdip_logfont_from_font (font, graphics, lf, TRUE);
 }
 
 GpStatus
 GdipGetLogFontA(GpFont *font, GpGraphics *graphics, void *lf)
 {
-               
-       if (!font || !lf) {
-               return(InvalidParameter);
-       }
-       
-       gdip_logfont_from_font(font, graphics, lf, FALSE);
-       return Ok;
+       return gdip_logfont_from_font (font, graphics, lf, FALSE);
 }
 
 GpStatus

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to