eina: promise: fix memory leak in error path

If we would not get a promise back here the allocated array would leak when we
return. Make sure we also free it in this case.

CID: 1360468
This commit is contained in:
Stefan Schmidt 2016-07-29 14:53:36 +02:00
parent 461c5d2787
commit 3bd4c19f55
1 changed files with 5 additions and 1 deletions

View File

@ -601,7 +601,11 @@ eina_promise_all(Eina_Iterator* it)
eina_iterator_free(it);
promise = eina_safepointer_get((Eina_Safepointer*)(safe_promise = eina_promise_add()));
if (!promise) return NULL;
if (!promise)
{
eina_array_free(promises);
return NULL;
}
internal_it = promise->pointer_value = malloc(sizeof(_Eina_Promise_Iterator) +
sizeof(_Eina_Promise_Default_Owner*) * eina_array_count_get(promises));