[librsvg/librsvg-2.40: 4/10] Check the limits after each draw-related operation



commit 66df77c16075f05c5d0f491bbbd3542d88c0ddb6
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 26 11:13:37 2020 -0600

    Check the limits after each draw-related operation

 rsvg-base.c         | 23 ++++++++++++++++++-----
 rsvg-cairo-render.c |  9 ++++++++-
 2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 68e93f63..da443f64 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1387,6 +1387,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
     RsvgNodeSvg *root = NULL;
     RsvgNode *sself = NULL;
     RsvgBbox bbox;
+    gboolean retval = FALSE;
 
     gboolean handle_subelement = TRUE;
 
@@ -1446,6 +1447,12 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
         rsvg_node_draw (handle->priv->treebase, draw, 0);
         bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;
 
+        if (rsvg_drawing_ctx_limits_exceeded (draw)) {
+            retval = FALSE;
+        } else {
+            retval = TRUE;
+        }
+
         cairo_restore (cr);
         rsvg_state_pop (draw);
         rsvg_drawing_ctx_free (draw);
@@ -1463,6 +1470,8 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
         dimension_data->height = (int) (_rsvg_css_hand_normalize_length (&root->h, handle->priv->dpi_y,
                                          bbox.rect.height + bbox.rect.y * 2,
                                          12) + 0.5);
+
+        retval = TRUE;
     }
     
     dimension_data->em = dimension_data->width;
@@ -1472,7 +1481,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
         (*handle->priv->size_func) (&dimension_data->width, &dimension_data->height,
                                     handle->priv->user_data);
 
-    return TRUE;
+    return retval;
 }
 
 /**
@@ -1498,7 +1507,7 @@ rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_d
     RsvgDimensionData    dimension_data;
     cairo_surface_t            *target = NULL;
     cairo_t                            *cr = NULL;
-    gboolean                    ret = FALSE;
+    gboolean                    retval = FALSE;
 
     g_return_val_if_fail (handle, FALSE);
     g_return_val_if_fail (position_data, FALSE);
@@ -1544,6 +1553,12 @@ rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_d
     rsvg_node_draw (handle->priv->treebase, draw, 0);
     bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;
 
+    if (rsvg_drawing_ctx_limits_exceeded (draw)) {
+        retval = FALSE;
+    } else {
+        retval = TRUE;
+    }
+
     cairo_restore (cr);
     rsvg_state_pop (draw);
     rsvg_drawing_ctx_free (draw);
@@ -1560,15 +1575,13 @@ rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_d
         (*handle->priv->size_func) (&dimension_data.width, &dimension_data.height,
                                     handle->priv->user_data);
 
-    ret = TRUE;
-
 bail:
     if (cr)
         cairo_destroy (cr);
     if (target)
         cairo_surface_destroy (target);
 
-    return ret;
+    return retval;
 }
 
 /** 
diff --git a/rsvg-cairo-render.c b/rsvg-cairo-render.c
index b8f332aa..1f4b0856 100644
--- a/rsvg-cairo-render.c
+++ b/rsvg-cairo-render.c
@@ -220,6 +220,7 @@ rsvg_handle_render_cairo_sub (RsvgHandle * handle, cairo_t * cr, const char *id)
 {
     RsvgDrawingCtx *draw;
     RsvgNode *drawsub = NULL;
+    gboolean retval = FALSE;
 
     g_return_val_if_fail (handle != NULL, FALSE);
 
@@ -248,11 +249,17 @@ rsvg_handle_render_cairo_sub (RsvgHandle * handle, cairo_t * cr, const char *id)
 
     rsvg_node_draw ((RsvgNode *) handle->priv->treebase, draw, 0);
 
+    if (rsvg_drawing_ctx_limits_exceeded (draw)) {
+        retval = FALSE;
+    } else {
+        retval = TRUE;
+    }
+
     cairo_restore (cr);
     rsvg_state_pop (draw);
     rsvg_drawing_ctx_free (draw);
 
-    return TRUE;
+    return retval;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]