From a1545ec314776d40f08486221aca37eb8073176e Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Fri, 12 Jun 2015 09:47:13 +0100 Subject: [PATCH] evas_smart: Add a check for zero size before malloc Summary: Size may be zero while allocating interfaces private data, when NULL is passed in EVAS_SMART_SUBCLASS_IFACE_NEW for ifaces argument. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free(). It is implementation dependent. This case would be likely to occur in case of smart classes with no interfaces. @fix Signed-off-by: Vaibhav Gupta Reviewers: raster, Hermet, tasn, cedric Subscribers: SanghyeonLee, sachin.dev, singh.amitesh, cedric Differential Revision: https://phab.enlightenment.org/D2679 --- src/lib/evas/canvas/evas_object_smart.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c index 252e71a..27fca2b 100644 --- a/src/lib/evas/canvas/evas_object_smart.c +++ b/src/lib/evas/canvas/evas_object_smart.c @@ -496,6 +496,8 @@ _evas_smart_class_ifaces_private_data_alloc(Evas_Object *eo_obj, } } + if (!s->interfaces.size && !total_priv_sz) return; + obj = eo_data_scope_get(eo_obj, MY_CLASS); obj->interface_privates = malloc(s->interfaces.size * sizeof(void *) + total_priv_sz); if (!obj->interface_privates) -- 2.7.4