atspi: remove memory leak 57/148057/2
authorShinwoo Kim <cinoo.kim@samsung.com>
Wed, 6 Sep 2017 11:09:26 +0000 (20:09 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 7 Sep 2017 03:43:38 +0000 (12:43 +0900)
The _elm_util_mkup_to_text gives alloacated plain text.
This plain text should be freed.

Change-Id: I4fe6443a2be78a80b00e79925b9ac968e489df76

13 files changed:
src/lib/elc_ctxpopup.c
src/lib/elc_multibuttonentry.c
src/lib/elc_naviframe.c
src/lib/elc_popup.c
src/lib/elm_entry.c
src/lib/elm_index.c
src/lib/elm_list.c
src/lib/elm_spinner.c
src/lib/elm_toolbar.c
src/lib/elm_widget.c
src/lib/elm_widget.h
src/lib/elm_win.c
src/mobile_lib/elc_ctxpopup.c

index 3fa0197..198a401 100644 (file)
@@ -1796,7 +1796,8 @@ _elm_ctxpopup_item_elm_interface_atspi_accessible_name_get(Eo *eo_it, Elm_Ctxpop
    eo_do_super(eo_it, ELM_CTXPOPUP_ITEM_CLASS, accessible_name = (char *)elm_interface_atspi_accessible_name_get());
    if (accessible_name) return accessible_name;
 
-   return _elm_util_mkup_to_text(elm_object_item_text_get(item->list_item));
+   return _elm_widget_item_accessible_plain_name_get(eo_it,
+                 elm_object_item_text_get(item->list_item));
 }
 //
 
index 401c1a0..c017b28 100644 (file)
@@ -2282,7 +2282,7 @@ _elm_multibuttonentry_item_elm_interface_atspi_accessible_name_get(Eo *eo_it, El
    eo_do_super(eo_it, ELM_MULTIBUTTONENTRY_ITEM_CLASS, ret = elm_interface_atspi_accessible_name_get());
    if (ret) return ret;
    ret = elm_object_part_text_get(VIEW(it), "elm.btn.text");
-   return _elm_util_mkup_to_text(ret);
+   return _elm_widget_item_accessible_plain_name_get(eo_it, ret);
 }
 
 EOLIAN static Elm_Atspi_State_Set
index bff2c61..ffba4ae 100644 (file)
@@ -621,7 +621,9 @@ _elm_naviframe_item_elm_widget_item_part_text_set(Eo *eo_it EINA_UNUSED,
         if (nit->title_label) strncat(buf, " ", 1);
         strncat(buf, nit->subtitle_label, sizeof(buf) - strlen(buf) - 2);
      }
-   eo_do(VIEW(it), elm_interface_atspi_accessible_name_set(_elm_util_mkup_to_text(buf)));
+   char *plain_text = _elm_util_mkup_to_text(buf);
+   eo_do(VIEW(it), elm_interface_atspi_accessible_name_set(plain_text));
+   free(plain_text);
 
    elm_layout_sizing_eval(WIDGET(nit));
 }
@@ -1410,7 +1412,10 @@ _item_new(Evas_Object *obj,
    //item base layout
    VIEW(it) = elm_layout_add(obj);
    eo_do(VIEW(it), elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_PAGE_TAB));
-   eo_do(VIEW(it), elm_interface_atspi_accessible_name_set(_elm_util_mkup_to_text((char*)title_label)));
+   char *plain_text = _elm_util_mkup_to_text((char*)title_label);
+   eo_do(VIEW(it), elm_interface_atspi_accessible_name_set(plain_text));
+   free(plain_text);
+
    evas_object_smart_member_add(VIEW(it), obj);
 
    if (!elm_widget_sub_object_add(obj, VIEW(it)))
index c39b0de..8cb820b 100644 (file)
@@ -453,7 +453,7 @@ _access_name_set_cb(void *data, Evas_Object *obj EINA_UNUSED)
 {
    char *text = NULL;
    if (data) text = _elm_util_mkup_to_text((char*)data);
-   if (text) return strdup(text);
+   if (text) return text;
    return NULL;
 }
 
@@ -2544,7 +2544,11 @@ _elm_popup_elm_interface_atspi_accessible_name_get(Eo *obj, Elm_Popup_Data *sd)
         else if (elm_object_part_text_get(obj, "elm.text"))
              utf8_text = _elm_util_mkup_to_text(elm_object_part_text_get(obj, "elm.text"));
 
-        if (utf8_text) eina_strbuf_append_printf(buf, ", %s", utf8_text);
+        if (utf8_text)
+          {
+             eina_strbuf_append_printf(buf, ", %s", utf8_text);
+             free(utf8_text);
+          }
      }
 
    accessible_name = eina_strbuf_string_steal(buf);
index 97aadcd..09e49be 100644 (file)
@@ -7805,17 +7805,17 @@ _elm_entry_elm_interface_atspi_accessible_state_set_get(Eo *obj, Elm_Entry_Data
 EOLIAN static const char*
 _elm_entry_elm_interface_atspi_accessible_name_get(Eo *obj, Elm_Entry_Data *sd)
 {
-   char *name = NULL;
-   eo_do_super(obj, ELM_ENTRY_CLASS, name = (char *)elm_interface_atspi_accessible_name_get());
+   const char *name = NULL;
+   eo_do_super(obj, ELM_ENTRY_CLASS, name = elm_interface_atspi_accessible_name_get());
    if (name && strncmp("", name, 1)) return name;
 
    if (sd->password) return NULL;
 
-   name = _elm_util_mkup_to_text(elm_entry_entry_get(obj));
+   name = _elm_widget_accessible_plain_name_get(obj, elm_entry_entry_get(obj));
    if (name && strncmp("", name, 1)) return name;
 
    const char *ret = edje_object_part_text_get(sd->entry_edje, "elm.guide");
-   return _elm_util_mkup_to_text(ret);
+   return _elm_widget_accessible_plain_name_get(obj, ret);
 }
 
 //TIZEN ONLY (20160609): Added atspi action interface in entry
index 2d891ad..0a1528c 100644 (file)
@@ -1807,9 +1807,9 @@ _elm_index_elm_interface_atspi_accessible_children_get(Eo *eo_it EINA_UNUSED, El
 }
 
 EOLIAN static const char*
-_elm_index_item_elm_interface_atspi_accessible_name_get(Eo *eo_it EINA_UNUSED, Elm_Index_Item_Data *data)
+_elm_index_item_elm_interface_atspi_accessible_name_get(Eo *eo_it, Elm_Index_Item_Data *data)
 {
-   return _elm_util_mkup_to_text(data->letter);
+   return _elm_widget_item_accessible_plain_name_get(eo_it, data->letter);
 }
 
 EOLIAN static const Elm_Atspi_Action*
index 9556277..58f3c14 100644 (file)
@@ -2194,9 +2194,9 @@ _elm_list_item_elm_interface_atspi_accessible_state_set_get(Eo *eo_it, Elm_List_
 }
 
 EOLIAN static const char*
-_elm_list_item_elm_interface_atspi_accessible_name_get(Eo *eo_it EINA_UNUSED, Elm_List_Item_Data *data)
+_elm_list_item_elm_interface_atspi_accessible_name_get(Eo *eo_it, Elm_List_Item_Data *data)
 {
-   return _elm_util_mkup_to_text(data->label);
+   return _elm_widget_item_accessible_plain_name_get(eo_it, data->label);
 }
 
 EOLIAN static Eina_List*
index 701ba56..421608b 100644 (file)
@@ -1924,7 +1924,7 @@ _elm_spinner_elm_interface_atspi_accessible_name_get(Eo *obj, Elm_Spinner_Data *
         ret = elm_layout_text_get(obj, "elm.text");
      }
    //
-   return _elm_util_mkup_to_text(ret);
+   return _elm_widget_accessible_plain_name_get(obj, ret);
 }
 
 // A11Y Accessibility - END
index 23e57dd..c877cce 100644 (file)
@@ -4128,7 +4128,7 @@ _elm_toolbar_item_elm_interface_atspi_accessible_name_get(Eo *eo_item, Elm_Toolb
    const char *ret;
    eo_do_super(eo_item, ELM_TOOLBAR_ITEM_CLASS, ret = elm_interface_atspi_accessible_name_get());
    if (ret) return ret;
-   return _elm_util_mkup_to_text(item->label);
+   return _elm_widget_item_accessible_plain_name_get(eo_item, item->label);
 }
 
 EOLIAN static Elm_Atspi_State_Set
index c661938..3c529c0 100644 (file)
@@ -5023,6 +5023,35 @@ _elm_widget_item_onscreen_is(Elm_Object_Item *item)
    return EINA_TRUE;
 }
 
+const char*
+_elm_widget_accessible_plain_name_get(Evas_Object *obj, const char* name)
+{
+   char *accessible_plain_name;
+
+   API_ENTRY return NULL;
+
+   accessible_plain_name = _elm_util_mkup_to_text(name);
+   eina_stringshare_del(sd->accessible_name);
+   sd->accessible_name =  eina_stringshare_add(accessible_plain_name);
+   free(accessible_plain_name);
+   return sd->accessible_name;
+}
+
+const char*
+_elm_widget_item_accessible_plain_name_get(Elm_Object_Item *item, const char* name)
+{
+   char *accessible_plain_name;
+
+   Elm_Widget_Item_Data *id = eo_data_scope_get(item, ELM_WIDGET_ITEM_CLASS);
+   if (!id) return NULL;
+
+   accessible_plain_name = _elm_util_mkup_to_text(name);
+   eina_stringshare_del(id->accessible_name);
+   id->accessible_name =  eina_stringshare_add(accessible_plain_name);
+   free(accessible_plain_name);
+   return id->accessible_name;
+}
+
 //TIZEN_ONLY(20161107): enhance elm_atspi_accessible_can_highlight_set to set can_hihglight property to its children
 EAPI Eina_Bool
 _elm_widget_item_highlightable(Elm_Object_Item *item)
@@ -6556,9 +6585,8 @@ _elm_widget_elm_interface_atspi_component_highlight_clear(Eo *obj, Elm_Widget_Sm
 //
 
 EOLIAN static const char*
-_elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
+_elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj, Elm_Widget_Smart_Data *_pd)
 {
-   char *accessible_name;
    //TIZEN_ONLY(20190922): add name callback, description callback.
    const char *ret = NULL;
    eo_do_super(obj, ELM_WIDGET_CLASS, ret = elm_interface_atspi_accessible_name_get());
@@ -6586,11 +6614,7 @@ _elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Wid
    ret = elm_object_text_get(obj);
    if (!ret) return NULL;
 
-   accessible_name = _elm_util_mkup_to_text(ret);
-   eina_stringshare_del(_pd->accessible_name);
-   _pd->accessible_name =  eina_stringshare_add(accessible_name);
-   free(accessible_name);
-   return _pd->accessible_name;
+   return _elm_widget_accessible_plain_name_get(obj, ret);
 }
 //TIZEN_ONLY(20161111) add widget/widget_item description get/set
 EOLIAN void
index 095d6c9..eb381bf 100644 (file)
@@ -888,6 +888,8 @@ EAPI void             elm_widget_tree_dump(const Evas_Object *top);
 EAPI void             elm_widget_tree_dot_dump(const Evas_Object *top, FILE *output);
 EAPI Eina_Bool        _elm_widget_onscreen_is(Evas_Object *widget);
 EAPI Eina_Bool        _elm_widget_item_onscreen_is(Elm_Object_Item *item);
+const char*           _elm_widget_accessible_plain_name_get(Evas_Object *obj, const char* name);
+const char*           _elm_widget_item_accessible_plain_name_get(Elm_Object_Item *item, const char* name);
 //TIZEN_ONLY(20161107): enhance elm_atspi_accessible_can_highlight_set to set can_hihglight property to its children
 EAPI Eina_Bool        _elm_widget_highlightable(Evas_Object *widget);
 EAPI Eina_Bool        _elm_widget_item_highlightable(Elm_Object_Item *item);
index 87fddf8..e788002 100644 (file)
@@ -7022,7 +7022,7 @@ _elm_win_elm_interface_atspi_accessible_name_get(Eo *obj, Elm_Win_Data *sd EINA_
    eo_do_super(obj, ELM_WIN_CLASS, ret = elm_interface_atspi_accessible_name_get());
    if (ret) return ret;
 
-   return _elm_util_mkup_to_text(elm_win_title_get(obj));
+   return _elm_widget_accessible_plain_name_get(obj, elm_win_title_get(obj));
 }
 
 #include "elm_win.eo.c"
index dba3bec..1b40920 100644 (file)
@@ -2680,7 +2680,7 @@ _elm_ctxpopup_item_elm_interface_atspi_accessible_name_get(Eo *eo_it, Elm_Ctxpop
         return icon_name;
      }
    else
-     return _elm_util_mkup_to_text(item->label);
+     return _elm_widget_item_accessible_plain_name_get(eo_it, item->label);
 }
 //