bu5hm4n pushed a commit to branch master.

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

commit 87e5907f18dee96c9e93a41f7a611aa362039813
Author: ali <[email protected]>
Date:   Thu Jan 2 12:52:22 2020 +0100

    efl.text: add null check for cursor and attribute internal methods
    
    Reviewers: woohyun, segfaultxavi, bu5hm4n, zmike
    
    Reviewed By: bu5hm4n
    
    Subscribers: ProhtMeyhet, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Reviewed-by: Marcel Hollerbach <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D10899
---
 src/lib/evas/canvas/efl_text_cursor.c    | 9 ++++++---
 src/lib/evas/canvas/efl_text_formatter.c | 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/lib/evas/canvas/efl_text_cursor.c 
b/src/lib/evas/canvas/efl_text_cursor.c
index b52298c1c0..eb699728b8 100644
--- a/src/lib/evas/canvas/efl_text_cursor.c
+++ b/src/lib/evas/canvas/efl_text_cursor.c
@@ -246,7 +246,8 @@ _cursor_text_append(Efl_Text_Cursor_Handle *cur,
    const char *off = text;
    int len = 0;
 
-   Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, 
EFL_CANVAS_OBJECT_CLASS);
+   Evas_Object_Protected_Data *obj = efl_data_scope_safe_get(cur->obj, 
EFL_CANVAS_OBJECT_CLASS);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0);
    evas_object_async_block(obj);
 
    while (*off)
@@ -412,7 +413,8 @@ _efl_text_cursor_range_delete(Eo *obj EINA_UNUSED, 
Efl_Text_Cursor_Data *pd, Efl
 EAPI void
 efl_text_cursor_handle_set(Eo *obj, Efl_Text_Cursor_Handle *handle)
 {
-   Efl_Text_Cursor_Data *pd = efl_data_scope_get(obj, MY_CLASS);
+   Efl_Text_Cursor_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
+   EINA_SAFETY_ON_NULL_RETURN(pd);
    if (handle == pd->handle)
      return;
 
@@ -429,7 +431,8 @@ efl_text_cursor_handle_set(Eo *obj, Efl_Text_Cursor_Handle 
*handle)
 EAPI Efl_Text_Cursor_Handle *
 efl_text_cursor_handle_get(const Eo *obj)
 {
-   Efl_Text_Cursor_Data *pd = efl_data_scope_get(obj, MY_CLASS);
+   Efl_Text_Cursor_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
    return pd->handle;
 }
 
diff --git a/src/lib/evas/canvas/efl_text_formatter.c 
b/src/lib/evas/canvas/efl_text_formatter.c
index 8325245cd2..aea3e42356 100644
--- a/src/lib/evas/canvas/efl_text_formatter.c
+++ b/src/lib/evas/canvas/efl_text_formatter.c
@@ -121,7 +121,8 @@ efl_text_formatter_item_geometry_get(const 
Efl_Text_Attribute_Handle *annotation
    Efl_Text_Cursor_Handle cur;
 
    Eo *eo_obj = annotation->obj;
-   Evas_Object_Protected_Data *obj_data = efl_data_scope_get(eo_obj, 
EFL_CANVAS_OBJECT_CLASS);
+   Evas_Object_Protected_Data *obj_data = efl_data_scope_safe_get(eo_obj, 
EFL_CANVAS_OBJECT_CLASS);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(obj_data, EINA_FALSE);
    evas_object_async_block(obj_data);
    _evas_textblock_relayout_if_needed(eo_obj);
 

-- 


Reply via email to