Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : epplets

Dir     : e16/epplets/api


Modified Files:
        epplet.c 


Log Message:
Fix segv and leak.

===================================================================
RCS file: /cvs/e/e16/epplets/api/epplet.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -3 -r1.137 -r1.138
--- epplet.c    13 Apr 2006 11:07:27 -0000      1.137
+++ epplet.c    13 Apr 2006 12:06:25 -0000      1.138
@@ -771,11 +771,23 @@
    XMaskEvent(disp, StructureNotifyMask, &ev);
 }
 
+static Epplet_gadget
+Epplet_gadget_check(Epplet_gadget g)
+{
+   int                 i;
+
+   for (i = 0; i < gad_num; i++)
+      if (gads[i] == g)
+         return g;
+
+   return NULL;
+}
+
 void
 Epplet_window_destroy_children(Epplet_window win)
 {
    int                 i, num;
-   Epplet_gadget      *lst;
+   Epplet_gadget      *lst, g;
 
    if (!gads || gad_num <= 0)
       return;
@@ -787,8 +799,14 @@
    memcpy(lst, gads, num * sizeof(Epplet_gadget));
 
    for (i = 0; i < num; i++)
-      if (((GadGeneral *) lst[i])->parent == win)
-        Epplet_gadget_destroy(lst[i]);
+     {
+       /* Check - Gadget may have been removed by recursive call */
+       g = Epplet_gadget_check(lst[i]);
+       if (!g)
+          continue;
+       if (((GadGeneral *) g)->parent == win)
+          Epplet_gadget_destroy(g);
+     }
 
    free(lst);
 }
@@ -4771,6 +4789,8 @@
                if (g->entry[i].gadget)
                   Epplet_gadget_destroy(g->entry[i].gadget);
             }
+          if (g->entry)
+            free(g->entry);
           XDestroyWindow(disp, g->win);
           XDeleteContext(disp, g->win, xid_context);
           free(g);




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to