multibuttonentry/spinner: Fix memory leak when eina_strbuf_string_steal is misused. 59/46959/3
authorYoungbok Shin <youngb.shin@samsung.com>
Fri, 7 Aug 2015 06:15:45 +0000 (15:15 +0900)
committerJaeun Choi <jaeun12.choi@samsung.com>
Thu, 27 Aug 2015 11:06:50 +0000 (04:06 -0700)
Summary:
_elm_access_say() does not free the given text.
But, the text from eina_strbuf_string_steal() is not cared
from outside of _elm_access_say(), too.
It should be changed to eina_strbuf_string_get().

Test Plan: N/A

Reviewers: cedric, woohyun, kimcinoo, JackDanielZ, Hermet

Reviewed By: Hermet

Differential Revision: https://phab.enlightenment.org/D2918

Change-Id: I50834be202ca0608af4a39dc0be293ed3eca0329
Origin: upstream

src/lib/elc_multibuttonentry.c
src/lib/elm_spinner.c

index d53f44b76f2ff2b5e6ce1944a9c53fb9859e48be..bfd3e35022cae6885393c768fe09020eaec67201 100644 (file)
@@ -440,7 +440,7 @@ _button_select(Evas_Object *obj,
                {
                   Evas_Object *ao, *po;
                   Eina_Strbuf *buf;
-                  const char *part, *text;
+                  const char *part;
 
                   part = "elm.btn.text";
                   po = (Evas_Object *)edje_object_part_object_get(btn, part);
@@ -452,8 +452,7 @@ _button_select(Evas_Object *obj,
                     "multi button entry item %s is selected",
                     edje_object_part_text_get(btn, part));
 
-                  text = (const char*)eina_strbuf_string_steal(buf);
-                  _elm_access_say(text);
+                  _elm_access_say(eina_strbuf_string_get(buf));
                   eina_strbuf_free(buf);
                }
           }
@@ -717,7 +716,6 @@ _button_item_add(Elm_Multibuttonentry_Data *sd,
    // ACCESS
    if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
      {
-        const char *text;
         Eina_Strbuf *buf;
         buf = eina_strbuf_new();
 
@@ -725,8 +723,7 @@ _button_item_add(Elm_Multibuttonentry_Data *sd,
           "multi button entry item %s is added",
           edje_object_part_text_get(item->button, "elm.btn.text"));
 
-        text = (const char*)eina_strbuf_string_steal(buf);
-        _elm_access_say(text);
+        _elm_access_say(eina_strbuf_string_get(buf));
         eina_strbuf_free(buf);
 
         _access_multibuttonentry_item_register(obj, eo_item, EINA_TRUE);
index 0823c9e365f85c75b157d4ff37271b2c8f36109e..49966662f809a5d5a33fff8805bd0129e45a9015 100644 (file)
@@ -771,10 +771,8 @@ _access_activate_cb(void *data,
    eina_strbuf_append_printf(buf, "%s, %s", text,
                              elm_layout_text_get(data, "elm.text"));
 
-   text = eina_strbuf_string_steal(buf);
+   _elm_access_say(eina_strbuf_string_get(buf));
    eina_strbuf_free(buf);
-
-   _elm_access_say(text);
 }
 
 static char *
@@ -825,7 +823,6 @@ static void
 _access_increment_decrement_info_say(Evas_Object *obj,
                                      Eina_Bool is_incremented)
 {
-   char *text;
    Eina_Strbuf *buf;
 
    ELM_SPINNER_DATA_GET(obj, sd);
@@ -847,9 +844,8 @@ _access_increment_decrement_info_say(Evas_Object *obj,
    eina_strbuf_append_printf
       (buf, "%s", elm_object_text_get(sd->text_button));
 
-   text = eina_strbuf_string_steal(buf);
+   _elm_access_say(eina_strbuf_string_get(buf));
    eina_strbuf_free(buf);
-   _elm_access_say(text);
 }
 
 static void