Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        iclass.c menus.c x.c 


Log Message:
Add sanity checks (oom cases).

===================================================================
RCS file: /cvs/e/e16/e/src/iclass.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -3 -r1.128 -r1.129
--- iclass.c    5 Jan 2008 10:22:32 -0000       1.128
+++ iclass.c    6 Jan 2008 14:08:40 -0000       1.129
@@ -683,6 +683,9 @@
    ImageClass         *ic;
 
    ic = ImageclassCreate(name);
+   if (!ic)
+      return NULL;
+
    ic->norm.normal = ImagestateCreate(image);
    ic->norm.normal->unloadable = 1;
    ImageclassPopulate(ic);
===================================================================
RCS file: /cvs/e/e16/e/src/menus.c,v
retrieving revision 1.294
retrieving revision 1.295
diff -u -3 -r1.294 -r1.295
--- menus.c     6 Jan 2008 14:02:26 -0000       1.294
+++ menus.c     6 Jan 2008 14:08:40 -0000       1.295
@@ -680,11 +680,18 @@
 void
 MenuAddItem(Menu * m, MenuItem * item)
 {
+   MenuItem          **items;
+
    if (!item)
       return;
+
+   items = EREALLOC(MenuItem *, m->items, m->num + 1);
+   if (!items)
+      return;
+
+   items[m->num] = item;
+   m->items = items;
    m->num++;
-   m->items = EREALLOC(MenuItem *, m->items, m->num);
-   m->items[m->num - 1] = item;
 }
 
 static void
===================================================================
RCS file: /cvs/e/e16/e/src/x.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -3 -r1.166 -r1.167
--- x.c 15 Dec 2007 12:36:58 -0000      1.166
+++ x.c 6 Jan 2008 14:08:40 -0000       1.167
@@ -1402,7 +1402,7 @@
    unsigned int        num_rects;
    int                 k, rn;
    int                 x, y, w, h;
-   XRectangle         *rects, *rl;
+   XRectangle         *rects, *rectsn, *rl;
 
    if (!win || win->w <= 0 || win->h <= 0)
       return 0;
@@ -1440,7 +1440,11 @@
        if (rn > 0)
          {
             rl = xch->rects;
-            rects = EREALLOC(XRectangle, rects, num_rects + rn);
+            rectsn = EREALLOC(XRectangle, rects, num_rects + rn);
+            if (!rectsn)
+               goto bail_out;
+            rects = rectsn;
+
             /* go through all clip rects in thsi window's shape */
             for (k = 0; k < rn; k++)
               {
@@ -1461,7 +1465,10 @@
        else if (rn == 0)
          {
             /* Unshaped */
-            rects = EREALLOC(XRectangle, rects, num_rects + 1);
+            rectsn = EREALLOC(XRectangle, rects, num_rects + 1);
+            if (!rectsn)
+               goto bail_out;
+            rects = rectsn;
 
             rects[num_rects].x = x;
             rects[num_rects].y = y;
@@ -1490,6 +1497,12 @@
      }
 
    return win->num_rect;
+
+ bail_out:
+   if (rects)
+      Efree(rects);
+   EShapeCombineMask(win, ShapeBounding, 0, 0, None, ShapeSet);
+   return 0;
 }
 
 void



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to