herdsman pushed a commit to branch master.

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

commit fcba96384f40fbff6f3b6c7fb1fbe3d0d7e62699
Author: Youngbok Shin <youngb.s...@samsung.com>
Date:   Sun Dec 13 17:13:13 2015 +0200

    Evas Textblock: Fix NULL dereferencing issue
    
    Summary:
    Even if the given two cursor is NULL, it shouldn't be crashed.
    @fix
    
    Test Plan:
    Test case included in Evas test suite.
    Run "make check".
    
    Reviewers: herdsman, tasn
    
    Subscribers: cedric, jpeg
    
    Differential Revision: https://phab.enlightenment.org/D3422
---
 src/lib/evas/canvas/evas_object_textblock.c | 14 +++++++-------
 src/tests/evas/evas_test_textblock.c        |  8 ++++++++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
b/src/lib/evas/canvas/evas_object_textblock.c
index d2bd6ee..48e7b3b 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -9873,9 +9873,6 @@ _evas_textblock_cursor_range_text_markup_get(const 
Evas_Textblock_Cursor *cur1,
    Eina_Strbuf *buf;
    Evas_Textblock_Cursor *cur2;
 
-   if (!cur1 || !cur1->node) return NULL;
-   if (!_cur2 || !_cur2->node) return NULL;
-   if (cur1->obj != _cur2->obj) return NULL;
    buf = eina_strbuf_new();
 
    if (evas_textblock_cursor_compare(cur1, _cur2) > 0)
@@ -9984,9 +9981,6 @@ _evas_textblock_cursor_range_text_plain_get(const 
Evas_Textblock_Cursor *cur1, c
    Evas_Object_Textblock_Node_Text *n1, *n2;
    Evas_Textblock_Cursor *cur2;
 
-   if (!cur1 || !cur1->node) return NULL;
-   if (!_cur2 || !_cur2->node) return NULL;
-   if (cur1->obj != _cur2->obj) return NULL;
    buf = eina_ustrbuf_new();
 
    if (evas_textblock_cursor_compare(cur1, _cur2) > 0)
@@ -10111,7 +10105,13 @@ evas_textblock_cursor_range_formats_get(const 
Evas_Textblock_Cursor *cur1, const
 EAPI char *
 evas_textblock_cursor_range_text_get(const Evas_Textblock_Cursor *cur1, const 
Evas_Textblock_Cursor *cur2, Evas_Textblock_Text_Type format)
 {
-   Evas_Object_Protected_Data *obj = eo_data_scope_get(cur1->obj, 
EVAS_OBJECT_CLASS);
+   Evas_Object_Protected_Data *obj;
+
+   if (!cur1 || !cur1->node) return NULL;
+   if (!cur2 || !cur2->node) return NULL;
+   if (cur1->obj != cur2->obj) return NULL;
+
+   obj = eo_data_scope_get(cur1->obj, EVAS_OBJECT_CLASS);
    evas_object_async_block(obj);
    if (format == EVAS_TEXTBLOCK_TEXT_MARKUP)
       return _evas_textblock_cursor_range_text_markup_get(cur1, cur2);
diff --git a/src/tests/evas/evas_test_textblock.c 
b/src/tests/evas/evas_test_textblock.c
index 6a0b7b1..467e164 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -2923,6 +2923,14 @@ START_TEST(evas_textblock_text_getters)
             "and now in english."));
 
    /* Range get */
+   /* If one of the given cursor is NULL, it returns NULL. */
+   fail_if(evas_textblock_cursor_range_text_get(NULL, NULL,
+            EVAS_TEXTBLOCK_TEXT_MARKUP));
+   fail_if(evas_textblock_cursor_range_text_get(cur, NULL,
+            EVAS_TEXTBLOCK_TEXT_MARKUP));
+   fail_if(evas_textblock_cursor_range_text_get(NULL, cur,
+            EVAS_TEXTBLOCK_TEXT_MARKUP));
+
    Evas_Textblock_Cursor *main_cur = evas_object_textblock_cursor_get(tb);
    evas_textblock_cursor_pos_set(main_cur, 2);
    evas_textblock_cursor_pos_set(cur, 2);

-- 


Reply via email to