[cairo-commit] src/win32

Adrian Johnson ajohnson at kemper.freedesktop.org
Fri Nov 13 02:58:03 PST 2015


 src/win32/cairo-win32-font.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit ad99e1b9d80a9dc8d185f38347d64e1db762523c
Author: Patrick Fritzsch <Patrick.Fritzsch at cib.de>
Date:   Fri Nov 13 21:16:22 2015 +1030

    win32: check if GetTextMetrics failed
    
    http://lists.cairographics.org/archives/cairo/2015-November/026544.html

diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index 1599b07..f5bd22c 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -889,7 +889,7 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
     cairo_status_t status;
     cairo_font_extents_t extents;
 
-    TEXTMETRIC metrics;
+    TEXTMETRIC metrics = {0};
     HDC hdc;
 
     hdc = _get_global_font_dc ();
@@ -902,8 +902,14 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
 	status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
 	if (status)
 	    return status;
-	GetTextMetrics (hdc, &metrics);
+
+	if (!GetTextMetrics (hdc, &metrics)) {
+	    status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_set_metrics:GetTextMetrics");
+	}
+
 	cairo_win32_scaled_font_done_font (&scaled_font->base);
+	if (status)
+	    return status;
 
 	extents.ascent = metrics.tmAscent / scaled_font->logical_scale;
 	extents.descent = metrics.tmDescent / scaled_font->logical_scale;


More information about the cairo-commit mailing list