[gimp] app: fix infinite recursion crash in gimp_item_is_position_locked()



commit acdf9bb29bba5c3016ea3dfedb82a13dc6f320a8
Author: Michael Natterer <mitch gimp org>
Date:   Sun Nov 11 17:17:47 2012 +0100

    app: fix infinite recursion crash in gimp_item_is_position_locked()
    
    When checking if any linked item is position-locked in
    gimp_item_linked_is_locked(), temporarily set the items to not being
    linked, or gimp_item_real_is_position_locked() will call
    gimp_item_linked_is_locked() again, and so on...

 app/core/gimpitem-linked.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/app/core/gimpitem-linked.c b/app/core/gimpitem-linked.c
index fe86e40..502aef7 100644
--- a/app/core/gimpitem-linked.c
+++ b/app/core/gimpitem-linked.c
@@ -49,15 +49,20 @@ gimp_item_linked_is_locked (const GimpItem *item)
 
   list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
 
-  for (l = list; l; l = g_list_next (l))
+  for (l = list; l && ! locked; l = g_list_next (l))
     {
       GimpItem *item = l->data;
 
+      /*  temporarily set the item to not being linked, or we will
+       *  run into a recursion because gimp_item_is_position_locked()
+       *  call this function if the item is linked
+       */
+      gimp_item_set_linked (item, FALSE, FALSE);
+
       if (gimp_item_is_position_locked (item))
-        {
-          locked = TRUE;
-          break;
-        }
+        locked = TRUE;
+
+      gimp_item_set_linked (item, TRUE, FALSE);
     }
 
   g_list_free (list);



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