WIN32 Font 15.14 Patch for difference malloc _cairo_malloc

Friedrich Westermann <[email protected]> Fri, 05 Oct 2018 08:22:07 +0200
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hello,

I have found a small Bug in the latest Cairo Win32. The change from malloc to _cairo_malloc breaks the 
_cairo_win32_scaled_font_init_glyph_path

_cairo:malloc returns NULL for bytesGlyph 0. 


Here is a Patch to fix it




Friedrich Westermann

-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
0001-fix-for-Win32-Font-Glyphs.patch (application/octet-stream, 1 KB)
From 029aff11bb3f5e0f32e26fcba11ad32cdff6b343 Mon Sep 17 00:00:00 2001
From: Westermann <[email protected]>
Date: Fri, 5 Oct 2018 07:56:29 +0200
Subject: [PATCH] fix for Win32 Font Glyphs

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

diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index a031c1363..f35f53dd3 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -1697,7 +1697,7 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
     }
 
     ptr = buffer = _cairo_malloc (bytesGlyph);
-    if (!buffer) {
+    if (bytesGlyph &&  !buffer) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto CLEANUP_FONT;
     }
@@ -1808,7 +1808,7 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
 				  path);
 
  CLEANUP_BUFFER:
-    free (buffer);
+  if (buffer)  free (buffer);
 
  CLEANUP_FONT:
     if (scaled_font->base.options.hint_style == CAIRO_HINT_STYLE_NONE)
-- 
2.18.0.windows.1