herdsman pushed a commit to branch master.

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

commit c23283944b7b07164b79bbd6957f75a1eccc65e5
Author: Jiwon Kim <jwkim0...@gmail.com>
Date:   Thu Mar 24 10:14:50 2016 +0200

    Evas textblock: fix null-derefernce in _style_match_tag()
    
    Summary:
    add null check in _style_match_tag()
    if evas_object_textblock_text_markup_set() is called with markup text 
before setting style,
    segmentation fault is occurred in _style_match_tag()
    @fix
    
    Test Plan:
    Insert this situation to test suite
     -> test id : evas_textblock_simple
    
    Test for without this patch:
     1. apply patch just "src/tests/evas/evas_test_textblock.c" partially.
     2. $make check
    
    Test for with this patch:
     1. apply this patch completely (2 files)
     2. $make check
    
    Reviewers: id213sin, herdsman
    
    Subscribers: Blackmole, cedric, jpeg
    
    Projects: #efl
    
    Differential Revision: https://phab.enlightenment.org/D3818
---
 src/lib/evas/canvas/evas_object_textblock.c | 13 ++++++++-----
 src/tests/evas/evas_test_textblock.c        |  8 ++++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
b/src/lib/evas/canvas/evas_object_textblock.c
index 8066f08..a30ca13 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -757,13 +757,16 @@ _style_match_tag(const Evas_Textblock_Style *ts, const 
char *s, size_t tag_len,
    Evas_Object_Style_Tag *tag;
 
    /* Try the style tags */
-   EINA_INLIST_FOREACH(ts->tags, tag)
+   if (ts)
      {
-        if (tag->tag.tag_len != tag_len) continue;
-        if (!strncmp(tag->tag.tag, s, tag_len))
+        EINA_INLIST_FOREACH(ts->tags, tag)
           {
-             *replace_len = tag->tag.replace_len;
-             return tag->tag.replace;
+             if (tag->tag.tag_len != tag_len) continue;
+             if (!strncmp(tag->tag.tag, s, tag_len))
+               {
+                  *replace_len = tag->tag.replace_len;
+                  return tag->tag.replace;
+               }
           }
      }
 
diff --git a/src/tests/evas/evas_test_textblock.c 
b/src/tests/evas/evas_test_textblock.c
index 63da902..1473f99 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -68,6 +68,14 @@ START_TEST(evas_textblock_simple)
    const char *buf = "Th<i>i</i>s is a <br/> te<b>s</b>t.";
    evas_object_textblock_text_markup_set(tb, buf);
    fail_if(strcmp(evas_object_textblock_text_markup_get(tb), buf));
+
+   /* Set markup text(includes tag) without setting style */
+   Evas_Object *tb2 = evas_object_textblock_add(evas);
+   fail_if(!tb2);
+   evas_object_textblock_text_markup_set(tb2, buf);
+   ck_assert("Crash Not occurred");
+   evas_object_del(tb2);
+
    END_TB_TEST();
 }
 END_TEST

-- 


Reply via email to