From 6690ee0c70f77265a7f27c4d24620125d18b933c Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Tue, 3 Oct 2017 08:32:51 -0400 Subject: [PATCH] Fix allocation of lua object. Size the malloc using zend's helper. Use ecalloc over emalloc to make sure uninit'd structs are clear. No need to check return value as e*alloc() funcs can't fail. --- lua.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua.c b/lua.c index d5f4acd..86ffaf9 100755 --- a/lua.c +++ b/lua.c @@ -197,12 +197,7 @@ zend_object *php_lua_create_object(zend_class_entry *ce) lua_atpanic(L, php_lua_atpanic); - intern = emalloc(sizeof(php_lua_object) + sizeof(zval) * (ce->default_properties_count - 1)); - - if (!intern) { - php_error_docref(NULL, E_ERROR, "alloc memory for lua object failed"); - } - + intern = ecalloc(1, sizeof(php_lua_object) + zend_object_properties_size(ce)); intern->L = L; zend_object_std_init(&intern->obj, ce);