efl_ui_text: Fix resource leak

Summary:
Coverity reports a resource leak here. When we return due to invalid
selection, we should free the 'ldata' that we previously allocated

Fixes Coverity CID1396998

@fix

Reviewers: raster, cedric, q66, zmike, bu5hm4n, stefan, stefan_schmidt

Reviewed By: cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8320
This commit is contained in:
Christopher Michael 2019-03-15 12:14:05 -04:00
parent 721f1776db
commit 12f0dc4fdd
1 changed files with 4 additions and 4 deletions

View File

@ -1164,9 +1164,6 @@ _selection_store(Efl_Ui_Selection_Type seltype,
Selection_Loss_Data *ldata;
Eina_Future *f;
ldata = calloc(1, sizeof(Selection_Loss_Data));
if (!ldata) return;
EFL_UI_TEXT_DATA_GET(obj, sd);
efl_text_interactive_selection_cursors_get(obj, &start, &end);
@ -1177,7 +1174,6 @@ _selection_store(Efl_Ui_Selection_Type seltype,
slice.len = strlen(sel);
slice.mem = sel;
switch (seltype)
{
case EFL_UI_SELECTION_TYPE_CLIPBOARD:
@ -1202,12 +1198,16 @@ _selection_store(Efl_Ui_Selection_Type seltype,
break;
}
ldata = calloc(1, sizeof(Selection_Loss_Data));
if (!ldata) goto end;
ldata->obj = obj;
eina_future_then_easy(f, _selection_lost_cb, NULL, NULL, EINA_VALUE_TYPE_UINT, ldata);
//if (seltype == EFL_UI_SELECTION_TYPE_CLIPBOARD)
// eina_stringshare_replace(&sd->cut_sel, sel);
end:
free(sel);
}