bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=58dedf4674c50ec4c434463fb49351f492a9e30d

commit 58dedf4674c50ec4c434463fb49351f492a9e30d
Author: Marcel Hollerbach <marcel-hollerb...@t-online.de>
Date:   Sun Sep 4 13:11:14 2016 +0200

    edje: protect against no file set yet.
    
    Summary:
    There can be the case that the file of a edje is NULL. Even if this case
    is a bit strange, we should not crash on it.
    
    Sample code which produces the crash:
    
       Edje_Object *edje;
       int r, g, b, a;
    
       edje = edje_object_add(evas);
    
       edje_obj_color_class_get(edje, "bla",
        EDJE_COLOR_CLASS_MODE_COLOR, &r, &g, &b, &a);
    
    So better protect against this case.
    
    Reviewers: raster, herdsman
    
    Subscribers: cedric, jpeg
    
    Differential Revision: https://phab.enlightenment.org/D4277
---
 src/lib/edje/edje_util.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 2144c02..4432821 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -772,6 +772,8 @@ _edje_color_class_apply(const char *color_class, const char 
*parent)
         _edje_recalc(er->ed);
         _edje_emit(er->ed, "color_class,set", parent);
 
+        if (!er->ed->file) continue;
+
         EINA_LIST_FOREACH(er->ed->file->color_tree, l, ctn)
           {
              if ((!strcmp(ctn->name, color_class)) && (ctn->color_classes))
@@ -901,7 +903,7 @@ _edje_color_class_active_iterator_next(Eina_Iterator *it, 
void **data)
    Eina_Hash_Tuple *tuple = NULL;
    Edje_Refcount *er = NULL;
    Eina_Iterator *ith;
-   Edje_Color_Class *cc;
+   Edje_Color_Class *cc = NULL;
    Eina_Bool r = EINA_FALSE;
 
    if (!eina_iterator_next(et->classes, (void **)&tuple)) return EINA_FALSE;
@@ -923,7 +925,8 @@ _edje_color_class_active_iterator_next(Eina_Iterator *it, 
void **data)
       Any of the Edje object referenced should have a file with a valid
       description for this color class. Let's bet on that for now.
     */
-   cc = eina_hash_find(er->ed->file->color_hash, tuple->key);
+   if (er->ed->file)
+     cc = eina_hash_find(er->ed->file->color_hash, tuple->key);
    if (!cc) goto on_error;
    et->cc.desc = cc->desc;
 
@@ -6083,7 +6086,8 @@ _edje_color_class_find(const Edje *ed, const char 
*color_class)
    if (cc) return cc;
 
    /* finally, look through the file scope */
-   cc = eina_hash_find(ed->file->color_hash, color_class);
+   if (ed->file)
+     cc = eina_hash_find(ed->file->color_hash, color_class);
    if (cc) return cc;
 
    return NULL;
@@ -6098,7 +6102,7 @@ _edje_color_class_recursive_find_helper(const Edje *ed, 
Eina_Hash *hash, const c
 
    cc = _edje_hash_find_helper(hash, color_class);
    if (cc) return cc;
-   else
+   else if (ed->file)
      {
         parent = color_class;
         while ((ctn = eina_hash_find(ed->file->color_tree_hash, parent)))
@@ -6127,7 +6131,8 @@ _edje_color_class_recursive_find(const Edje *ed, const 
char *color_class)
    if (cc) return cc;
 
    /* finally, look through the file scope */
-   cc = _edje_color_class_recursive_find_helper(ed, ed->file->color_hash, 
color_class);
+   if (ed->file)
+     cc = _edje_color_class_recursive_find_helper(ed, ed->file->color_hash, 
color_class);
    if (cc) return cc;
 
    return NULL;
@@ -6208,7 +6213,8 @@ _edje_text_class_find(Edje *ed, const char *text_class)
    if (tc) return tc;
 
    /* finally, look through the file scope */
-   tc = eina_hash_find(ed->file->text_hash, text_class);
+   if (ed->file)
+     tc = eina_hash_find(ed->file->text_hash, text_class);
    if (tc) return tc;
 
    return NULL;
@@ -6277,7 +6283,8 @@ _edje_size_class_find(Edje *ed, const char *size_class)
    if (sc) return sc;
 
    /* finally, look through the file scope */
-   sc = eina_hash_find(ed->file->size_hash, size_class);
+   if (ed->file)
+     sc = eina_hash_find(ed->file->size_hash, size_class);
    if (sc) return sc;
 
    return NULL;

-- 


Reply via email to