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
This commit is contained in:
Christopher Michael 2019-04-01 10:02:57 -04:00
parent 750b21830f
commit 83d4890c74
1 changed files with 11 additions and 6 deletions

View File

@ -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;
}