recording: Prevent invalid memory access with zero length command array

If we try to sort a zero length array, we access invalid memory.
However, for a zero length command array, we can trivially compute the
number of visible indices, 0.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-06-18 15:46:28 +01:00
parent c51b850bd8
commit df1ca22ada

View file

@ -1586,6 +1586,9 @@ _cairo_recording_surface_get_visible_commands (cairo_recording_surface_t *surfac
unsigned int num_visible, *indices;
cairo_box_t box;
if (surface->commands.num_elements == 0)
return 0;
_cairo_box_from_rectangle (&box, extents);
if (surface->bbtree.chain == INVALID_CHAIN)