forked from enlightenment/efl
elementary: unref objects when memory allocation fails in factory
The objects referenced are unreferenced when memory allocation fails in elementary factory. Differential Revision: https://phab.enlightenment.org/D9968
This commit is contained in:
parent
eb2c1311ae
commit
98c2a75bda
|
@ -180,6 +180,7 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
|
||||||
Efl_Ui_Caching_Factory_Data *pd,
|
Efl_Ui_Caching_Factory_Data *pd,
|
||||||
Eina_Iterator *models, Efl_Gfx_Entity *parent)
|
Eina_Iterator *models, Efl_Gfx_Entity *parent)
|
||||||
{
|
{
|
||||||
|
Efl_Ui_Caching_Factory_Request *r;
|
||||||
Efl_Ui_Caching_Factory_Group_Request *gr;
|
Efl_Ui_Caching_Factory_Group_Request *gr;
|
||||||
Efl_Gfx_Entity *w = NULL;
|
Efl_Gfx_Entity *w = NULL;
|
||||||
Efl_Model *model;
|
Efl_Model *model;
|
||||||
|
@ -187,7 +188,6 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
|
||||||
|
|
||||||
if (pd->cache && pd->style && !pd->klass)
|
if (pd->cache && pd->style && !pd->klass)
|
||||||
{
|
{
|
||||||
Efl_Ui_Caching_Factory_Request *r;
|
|
||||||
Eina_Future **all;
|
Eina_Future **all;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
@ -199,11 +199,7 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
|
||||||
r->factory = efl_ref(obj);
|
r->factory = efl_ref(obj);
|
||||||
|
|
||||||
all = calloc(1, sizeof (Eina_Future *));
|
all = calloc(1, sizeof (Eina_Future *));
|
||||||
if (!all)
|
if (!all) goto alloc_array_error;
|
||||||
{
|
|
||||||
free(r);
|
|
||||||
return efl_loop_future_rejected(obj, ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(models, model)
|
EINA_ITERATOR_FOREACH(models, model)
|
||||||
{
|
{
|
||||||
|
@ -213,11 +209,7 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
|
||||||
.data = r);
|
.data = r);
|
||||||
|
|
||||||
all = realloc(all, (count + 1) * sizeof (Eina_Future *));
|
all = realloc(all, (count + 1) * sizeof (Eina_Future *));
|
||||||
if (!all)
|
if (!all) goto alloc_array_error;
|
||||||
{
|
|
||||||
free(r);
|
|
||||||
return efl_loop_future_rejected(obj, ENOMEM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
eina_iterator_free(models);
|
eina_iterator_free(models);
|
||||||
|
|
||||||
|
@ -274,6 +266,13 @@ _efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
|
||||||
.success_type = EINA_VALUE_TYPE_ARRAY,
|
.success_type = EINA_VALUE_TYPE_ARRAY,
|
||||||
.data = gr,
|
.data = gr,
|
||||||
.free = _efl_ui_caching_factory_group_cleanup);
|
.free = _efl_ui_caching_factory_group_cleanup);
|
||||||
|
|
||||||
|
alloc_array_error:
|
||||||
|
efl_unref(r->parent);
|
||||||
|
efl_unref(r->factory);
|
||||||
|
free(r);
|
||||||
|
eina_iterator_free(models);
|
||||||
|
return efl_loop_future_rejected(obj, ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -201,11 +201,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
|
||||||
r->factory = efl_ref(obj);
|
r->factory = efl_ref(obj);
|
||||||
|
|
||||||
f = calloc(count + 1, sizeof (Eina_Future *));
|
f = calloc(count + 1, sizeof (Eina_Future *));
|
||||||
if (!f)
|
if (!f) goto alloc_array_error;
|
||||||
{
|
|
||||||
free(r);
|
|
||||||
return efl_loop_future_rejected(obj, ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(models, model)
|
EINA_ITERATOR_FOREACH(models, model)
|
||||||
{
|
{
|
||||||
|
@ -214,11 +210,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
|
||||||
.free = _efl_ui_widget_factory_single_cleanup);
|
.free = _efl_ui_widget_factory_single_cleanup);
|
||||||
|
|
||||||
f = realloc(f, (count + 1) * sizeof (Eina_Future *));
|
f = realloc(f, (count + 1) * sizeof (Eina_Future *));
|
||||||
if (!f)
|
if (!f) goto alloc_array_error;
|
||||||
{
|
|
||||||
free(r);
|
|
||||||
return efl_loop_future_rejected(obj, ENOMEM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
eina_iterator_free(models);
|
eina_iterator_free(models);
|
||||||
|
|
||||||
|
@ -227,6 +219,13 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
|
||||||
return efl_future_then(obj, eina_future_all_array(f),
|
return efl_future_then(obj, eina_future_all_array(f),
|
||||||
.data = r,
|
.data = r,
|
||||||
.free = _efl_ui_widget_factory_create_cleanup);
|
.free = _efl_ui_widget_factory_create_cleanup);
|
||||||
|
|
||||||
|
alloc_array_error:
|
||||||
|
efl_unref(r->parent);
|
||||||
|
efl_unref(r->factory);
|
||||||
|
free(r);
|
||||||
|
eina_iterator_free(models);
|
||||||
|
return efl_loop_future_rejected(obj, ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue