From 12f0dc4fdd46d66433cf9b053ed615f122b9314d Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Fri, 15 Mar 2019 12:14:05 -0400 Subject: [PATCH] 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 --- src/lib/elementary/efl_ui_text.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c index f5a2ddedb1..b00268993b 100644 --- a/src/lib/elementary/efl_ui_text.c +++ b/src/lib/elementary/efl_ui_text.c @@ -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); }