diff options
authorBryce Harrington <>2018-10-17 17:32:10 -0700
committerBryce Harrington <>2018-10-17 17:32:10 -0700
commit3a03c1ba4bc30492721abdb6c9ec8868663ef237 (patch)
parent7786b8fe4e7a2c73767be3ce7ae64389d09984d9 (diff)
win32: Fix regression with text containing space character
Converting a series of glyphs to a path triggers an out of memory error if there is a space glyph (bytesGlyph==0). The regression was introduced by commit 19982393 in cairo-win32-font.c:107. The behavior of malloc(0) is not well defined - it can return NULL on some platforms, or an arbitrary (non-allocated) pointer on other platforms. Commit 19982393 introduced sanity by enforcing that NULL is always returned in this situation, which inappropriately triggers the OOM check in _cairo_win32_scaled_font_init_glyph_path(). Instead, special case the handling for bytesGlyph==0. Patch authored by Uli Schlachter, based on fix proposed by lb90. Fixes: Reference: Reviewed-by: Bryce Harrington <>
1 files changed, 1 insertions, 1 deletions
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index a031c1363..1f217573b 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 (!buffer && bytesGlyph != 0) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);