win32: Fix regression with text containing space character
commit3a03c1ba4bc30492721abdb6c9ec8868663ef237
authorBryce Harrington <bryce@bryceharrington.org>
Thu, 18 Oct 2018 00:32:10 +0000 (17 17:32 -0700)
committerBryce Harrington <bryce@bryceharrington.org>
Thu, 18 Oct 2018 00:32:10 +0000 (17 17:32 -0700)
tree3363f46b6119422f1ac6bf5a4cba66a246ecf4b2
parent7786b8fe4e7a2c73767be3ce7ae64389d09984d9
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:  https://gitlab.freedesktop.org/cairo/cairo/issues/339
Reference:  https://gitlab.gnome.org/GNOME/pango/issues/323
Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
src/win32/cairo-win32-font.c