[cairo-commit] src/cairo-recording-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Jun 18 07:48:49 PDT 2013


 src/cairo-recording-surface.c |    3 +++
 1 file changed, 3 insertions(+)

New commits:
commit df1ca22ada340add2360677ff892ec043dad96f4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 18 15:46:28 2013 +0100

    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 at chris-wilson.co.uk>

diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 28d8abd..55a98d0 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -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)


More information about the cairo-commit mailing list