devilhorns pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=a8ba4c28fbfe51a84bc856b6729e4ec3a1610c80
commit a8ba4c28fbfe51a84bc856b6729e4ec3a1610c80 Author: Chris Michael <[email protected]> Date: Mon Sep 26 14:01:15 2016 -0400 elementary: Fix potential resource leak If we fail to allocate memory for savedtypes.types here, then the "known" array would end up leaking. Defer creation of 'known' array until after savedtypes.types is allocated, this way we don't leak. Fixes CID1363216 Signed-off-by: Chris Michael <[email protected]> --- src/lib/elementary/elm_cnp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c index fa379de..dfe3ae7 100644 --- a/src/lib/elementary/elm_cnp.c +++ b/src/lib/elementary/elm_cnp.c @@ -3477,7 +3477,6 @@ _wl_dnd_enter(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) ev = event; - known = eina_array_new(5); available = ecore_wl2_offer_mimes_get(ev->offer); free(savedtypes.types); @@ -3486,9 +3485,12 @@ _wl_dnd_enter(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) savedtypes.types = malloc(sizeof(char *) * savedtypes.ntypes); if (!savedtypes.types) return EINA_FALSE; + known = eina_array_new(5); + for (i = 0; i < eina_array_count(available); i++) { - savedtypes.types[i] = eina_stringshare_add(eina_array_data_get(available, i)); + savedtypes.types[i] = + eina_stringshare_add(eina_array_data_get(available, i)); if (savedtypes.types[i] == text_uri) { savedtypes.textreq = 1; --
