xcb: Don't crash when swapping a 0-sized glyph

malloc(0) needn't return NULL, and on glibc, doesn't.  Then we encounter
a loop of the form do { ... } while (--c), which doesn't do quite what
you were hoping for when c is initially 0.

Since there's nothing to swap in this case, just bomb out.

Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Adam Jackson 2014-10-31 13:21:15 -04:00 committed by Bryce Harrington
parent 40f1da3b42
commit bd2b4ab43e

View file

@ -4470,6 +4470,9 @@ _cairo_xcb_surface_add_glyph (cairo_xcb_connection_t *connection,
const uint8_t *d;
uint8_t *new, *n;
if (c == 0)
break;
new = malloc (c);
if (unlikely (new == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -4498,6 +4501,9 @@ _cairo_xcb_surface_add_glyph (cairo_xcb_connection_t *connection,
const uint32_t *d;
uint32_t *new, *n;
if (c == 0)
break;
new = malloc (4 * c);
if (unlikely (new == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);