From 5ed7378303c5f7ed3efeab307b57dcadfa00f7f5 Mon Sep 17 00:00:00 2001 From: JEONGHYUN YUN Date: Thu, 6 Apr 2017 14:23:19 -0700 Subject: [PATCH] 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 --- src/lib/edje/edje_edit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index d2616fc..ac387b3 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -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++; \ -- 2.7.4