edje_edit: add NULL check for eina_mempool_malloc in _edje_edit_state_alloc()
Summary: Pointer eina_mempool_malloc return value may have NULL value when module aren't properly installed. This reduce the chance of a crash and increase the likelyness of properly handling the failure. Reviewers: jpeg, jypark Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4763 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
3aa0ce099f
commit
5ed7378303
|
@ -6307,31 +6307,36 @@ _edje_edit_state_alloc(int type, Edje *ed)
|
|||
{
|
||||
case EDJE_PART_TYPE_RECTANGLE:
|
||||
pd = eina_mempool_malloc(ce->mp->mp.RECTANGLE, sizeof (Edje_Part_Description_Common));
|
||||
if (!pd) return NULL;
|
||||
ce->count.RECTANGLE++;
|
||||
break;
|
||||
|
||||
case EDJE_PART_TYPE_SPACER:
|
||||
pd = eina_mempool_malloc(ce->mp->mp.SPACER, sizeof (Edje_Part_Description_Common));
|
||||
if (!pd) return NULL;
|
||||
ce->count.SPACER++;
|
||||
break;
|
||||
|
||||
case EDJE_PART_TYPE_SWALLOW:
|
||||
pd = eina_mempool_malloc(ce->mp->mp.SWALLOW, sizeof (Edje_Part_Description_Common));
|
||||
if (!pd) return NULL;
|
||||
ce->count.SWALLOW++;
|
||||
break;
|
||||
|
||||
case EDJE_PART_TYPE_GROUP:
|
||||
pd = eina_mempool_malloc(ce->mp->mp.GROUP, sizeof (Edje_Part_Description_Common));
|
||||
if (!pd) return NULL;
|
||||
ce->count.GROUP++;
|
||||
break;
|
||||
|
||||
#define EDIT_ALLOC_POOL(Short, Type, Name) \
|
||||
case EDJE_PART_TYPE_##Short: \
|
||||
{ \
|
||||
Edje_Part_Description_##Type * Name; \
|
||||
Edje_Part_Description_##Type *Name = NULL; \
|
||||
\
|
||||
Name = eina_mempool_malloc(ce->mp->mp.Short, \
|
||||
sizeof (Edje_Part_Description_##Type)); \
|
||||
if (!Name) return NULL; \
|
||||
memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \
|
||||
pd = &Name->common; \
|
||||
ce->count.Short++; \
|
||||
|
|
Loading…
Reference in New Issue