[prev in list] [next in list] [prev in thread] [next in thread] 

List:       enlightenment-svn
Subject:    E CVS: libs/ebg cpk
From:       enlightenment-cvs () lists ! sourceforge ! net
Date:       2002-01-26 21:22:52
[Download RAW message or body]

Enlightenment CVS committal

Author  : cpk
Project : e17
Module  : libs/ebg

Dir     : e17/libs/ebg/src


Modified Files:
	e_bg.c 


Log Message:
Segfault protection when passing NULL arguments to ebg calls.
The testapp doesn't segfault any more when I pass it non-background dbs.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ebg/src/e_bg.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_bg.c	2002/01/25 19:28:09	1.3
+++ e_bg.c	2002/01/26 21:22:52	1.4
@@ -34,8 +34,9 @@
 {
    Evas_List l;
 
-   if (!bl)
+   if (!bg || !bl)
       return;
+
    if (bl->file)
       free(bl->file);
    bl->file = NULL;
@@ -71,17 +72,24 @@
    int i;
    Evas_List l;
 
+   if (!bg)
+      return NULL;
+
+   /* FIXME should this check for num >= 0? */
+
    for (i = 0, l = bg->layers; l; l = l->next, i++)
    {
       if (i == num)
          return l->data;
    }
+
    return NULL;
 }
 
 /**
  * e_bg_new - allocate a new E_Background struct
- * Returns a zeroed out E_Background struct
+ * Returns a zeroed out E_Background struct, NULL
+ * if there is not enough memory available.
  */
 E_Background
 e_bg_new(void)
@@ -89,6 +97,10 @@
    E_Background bg;
 
    bg = (E_Background) malloc(sizeof(struct _E_Background));
+
+   if (!bg)
+     return NULL;
+
    memset(bg, 0, sizeof(struct _E_Background));
    return bg;
 }
@@ -102,6 +114,9 @@
 {
    Evas_List l;
 
+   if (!bg)
+      return;
+
    for (l = bg->layers; l; l = l->next)
    {
       E_Background_Layer bl;
@@ -132,6 +147,9 @@
    E_DB_File *db;
    int i, num = 0;
 
+   if (!file || !*file)
+      return NULL;
+
    db = e_db_open_read(file);
 
    /* not a db, return NULL */
@@ -278,6 +296,9 @@
    Evas_List l;
    int i;
 
+   if (!bg || !file || !*file)
+     return;
+
    unlink(file);
    db = e_db_open(file);
    if (!db)
@@ -424,6 +445,9 @@
    Evas_List l;
    int ww, hh, count;
 
+   if (!bg || !evas)
+      return;
+
    if (bg->evas)
       return;
    bg->evas = evas;
@@ -497,12 +521,17 @@
 {
    Evas_List l;
 
+   if (!bg)
+      return;
+
    if ((bg->geom.sx == sx) && (bg->geom.sy == sy))
       return;
+
    bg->geom.sx = sx;
    bg->geom.sy = sy;
    if (!bg->evas)
       return;
+
    for (l = bg->layers; l; l = l->next)
    {
       E_Background_Layer bl;
@@ -527,6 +556,9 @@
 void
 e_bg_set_layer(E_Background bg, int layer)
 {
+   if (!bg)
+      return;
+
    if (bg->evas)
    {
       Evas_List l;
@@ -558,12 +590,16 @@
    Evas_List l;
    int i;
 
+   if (!bg)
+      return;
    if (!bg->evas)
       return;
    if ((bg->geom.w == w) && (bg->geom.h == h))
       return;
+
    bg->geom.w = w;
    bg->geom.h = h;
+
    for (i = 0, l = bg->layers; l; l = l->next, i++)
    {
       E_Background_Layer bl;
@@ -655,6 +691,9 @@
 e_bg_set_color_class(E_Background bg, char *cc, int r, int g, int b, int a)
 {
    Evas_List l;
+
+   if (!bg)
+     return;
 
    for (l = bg->layers; l; l = l->next)
    {



_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic