summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2020-04-13 15:16:04 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2020-04-13 15:16:05 +0900
commitd43515d9dcc51df92838db929417d6715a5720bf (patch)
treebcec1e35aabb02c3969469264c25873ab292b15a
parentf9ae39ef52b33c1af2c81b864a1f77657fd8e6d9 (diff)
elm_cnp: fix memory leaks
Summary: In copy and paste logic, there are some memory leaks logic. so fixed. @fix Reviewers: bu5hm4n, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11690
-rw-r--r--src/lib/elementary/elm_cnp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c
index ab17f5f3e4..1833c0b3d4 100644
--- a/src/lib/elementary/elm_cnp.c
+++ b/src/lib/elementary/elm_cnp.c
@@ -84,10 +84,12 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
84 const char *mime_type; 84 const char *mime_type;
85 Eina_Slice data; 85 Eina_Slice data;
86 Eina_Array *tmp; 86 Eina_Array *tmp;
87 unsigned char *mem_buf = NULL;
87 88
88 if (format == ELM_SEL_FORMAT_TEXT && ((char*)buf)[buflen - 1] != '\0') 89 if (format == ELM_SEL_FORMAT_TEXT && ((char*)buf)[buflen - 1] != '\0')
89 { 90 {
90 data.mem = eina_memdup((unsigned char *)buf, buflen, EINA_TRUE); 91 mem_buf = eina_memdup((unsigned char *)buf, buflen, EINA_TRUE);
92 data.mem = mem_buf;
91 data.len = buflen + 1; 93 data.len = buflen + 1;
92 } 94 }
93 else 95 else
@@ -108,6 +110,9 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
108 content = eina_content_new(data, mime_type); 110 content = eina_content_new(data, mime_type);
109 _register_selection_changed(obj); 111 _register_selection_changed(obj);
110 112
113 if (mem_buf != NULL)
114 free(mem_buf);
115
111 return ecore_evas_selection_set(ee, _default_seat(obj), _elm_sel_type_to_ee_type(selection), content); 116 return ecore_evas_selection_set(ee, _default_seat(obj), _elm_sel_type_to_ee_type(selection), content);
112} 117}
113 118
@@ -199,10 +204,12 @@ _callback_storage_deliver(Eo *obj, void *data, const Eina_Value value)
199 } 204 }
200 else 205 else
201 { 206 {
202 EINA_SAFETY_ON_FALSE_RETURN_VAL(format == ELM_SEL_FORMAT_TEXT || format == ELM_SEL_FORMAT_MARKUP || format == ELM_SEL_FORMAT_HTML, EINA_VALUE_EMPTY); 207 EINA_SAFETY_ON_FALSE_GOTO(format == ELM_SEL_FORMAT_TEXT || format == ELM_SEL_FORMAT_MARKUP || format == ELM_SEL_FORMAT_HTML, end);
203 208
204 _elm_entry_entry_paste(obj, (const char *) d.data); 209 _elm_entry_entry_paste(obj, (const char *) d.data);
205 } 210 }
211
212end:
206 free(d.data); 213 free(d.data);
207 214
208 return EINA_VALUE_EMPTY; 215 return EINA_VALUE_EMPTY;