mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-02 15:40:45 +02:00
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:
parent
40f1da3b42
commit
bd2b4ab43e
1 changed files with 6 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue