diff options
author | Christopher Michael <cp.michael@samsung.com> | 2019-04-01 10:02:57 -0400 |
---|---|---|
committer | Christopher Michael <cp.michael@samsung.com> | 2019-04-01 10:02:57 -0400 |
commit | 83d4890c74a91f9f2a61b3e2e515fbab0da155c3 (patch) | |
tree | a7c9a186b65d685e7479f63bdf8e1527330cc45d | |
parent | 750b21830fee07186a5523c1f90d220d743b0b48 (diff) | |
download | efl-83d4890c74a91f9f2a61b3e2e515fbab0da155c3.tar.gz |
efl_ui_selection_manager: Don't leak malloc'd data
Summary:
Coverity reports that we potentially leak char *s here. If we do not
have 'data_ret', then the malloc'd 's' sould be freed as we are not
going to use it.
Fixes Coverity CID1396949
@fix
Reviewers: raster, cedric, bu5hm4n, zmike
Reviewed By: bu5hm4n
Subscribers: #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8523
-rw-r--r-- | src/lib/elementary/efl_ui_selection_manager.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/elementary/efl_ui_selection_manager.c b/src/lib/elementary/efl_ui_selection_manager.c index ef9d221d0d..cbef9226af 100644 --- a/src/lib/elementary/efl_ui_selection_manager.c +++ b/src/lib/elementary/efl_ui_selection_manager.c @@ -1142,15 +1142,20 @@ static Eina_Bool _x11_vcard_send(char *target EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret, Ecore_X_Atom *ttype EINA_UNUSED, int *typesize EINA_UNUSED) { Sel_Manager_Selection *sel; - char *s; sel_debug("Vcard send called"); sel = *(Sel_Manager_Selection **)data; - s = malloc(sel->data.len + 1); - if (!s) return EINA_FALSE; - memcpy(s, sel->data.mem, sel->data.len); - s[sel->data.len] = 0; - if (data_ret) *data_ret = s; + if (data_ret) + { + char *s; + + s = malloc(sel->data.len + 1); + if (!s) return EINA_FALSE; + memcpy(s, sel->data.mem, sel->data.len); + s[sel->data.len] = 0; + *data_ret = s; + } + if (size_ret) *size_ret = sel->data.len; return EINA_TRUE; } |