[cairo-commit] src/cairo-default-context.c

Andrea Canciani ranma42 at kemper.freedesktop.org
Sat Jul 30 00:53:03 PDT 2011


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

New commits:
commit 6155348966b89a216d2e5ee0b4784507a0226a9f
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jul 30 09:46:33 2011 +0200

    default-context: Do not allow restoring pushed gstates
    
    The brackets defined by push/pop and save/restore are independent ad
    should match properly.
    
    This means that cairo_push()-ed gstates cannot be cairo_restore()-d
    and cairo_save()-d gstates cannot be cairo_pop()-ed.
    
    Fixes group-state.

diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index 1798e5c..4124632 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -119,6 +119,9 @@ _cairo_default_context_restore (void *abstract_cr)
 {
     cairo_default_context_t *cr = abstract_cr;
 
+    if (unlikely (_cairo_gstate_is_group (cr->gstate)))
+	return _cairo_error (CAIRO_STATUS_INVALID_RESTORE);
+
     return _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist);
 }
 


More information about the cairo-commit mailing list