[gtk+/wip/matthiasc/gadget-for-merge-2: 24/32] css node: Warn more



commit b4f9f2449d8c2a782cafa1ebf4cae575353ae251
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 8 16:51:21 2015 -0500

    css node: Warn more
    
    gtk_css_node_insert_before/after can easily create cycles
    which later lead to stack overflows. Even if we're not
    catching all cycles here, at least we can detect obviously
    invalid arguments, such as inserting a node next to itself.

 gtk/gtkcssnode.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 0772369..738d1e9 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -873,6 +873,7 @@ gtk_css_node_insert_after (GtkCssNode *parent,
                            GtkCssNode *previous_sibling)
 {
   g_return_if_fail (previous_sibling == NULL || previous_sibling->parent == parent);
+  g_return_if_fail (cssnode != previous_sibling);
 
   if (cssnode->previous_sibling == previous_sibling &&
       cssnode->parent == parent)
@@ -890,6 +891,7 @@ gtk_css_node_insert_before (GtkCssNode *parent,
                             GtkCssNode *next_sibling)
 {
   g_return_if_fail (next_sibling == NULL || next_sibling->parent == parent);
+  g_return_if_fail (cssnode != next_sibling);
 
   if (cssnode->next_sibling == next_sibling && 
       cssnode->parent == parent)


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