summaryrefslogtreecommitdiff
path: root/Zend/zend_objects_API.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-11-25 18:02:01 +0100
committerNikita Popov <nikita.ppv@gmail.com>2017-11-25 18:02:01 +0100
commit721f2cc51365527a1c70fc788a3b095503963887 (patch)
tree2c3c4a350b5d0c64de5a58c6d4123e6ca0a9d502 /Zend/zend_objects_API.h
parentb72b1a4e4d4a94a16b953bf8d826885efb56eeca (diff)
downloadphp-git-721f2cc51365527a1c70fc788a3b095503963887.tar.gz
Subtract one zval from memset
Diffstat (limited to 'Zend/zend_objects_API.h')
-rw-r--r--Zend/zend_objects_API.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h
index cffd9ee273..fbcb7059b4 100644
--- a/Zend/zend_objects_API.h
+++ b/Zend/zend_objects_API.h
@@ -90,7 +90,9 @@ static zend_always_inline size_t zend_object_properties_size(zend_class_entry *c
* Properties MUST be initialized using object_properties_init(). */
static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
void *obj = emalloc(obj_size + zend_object_properties_size(ce));
- memset(obj, 0, obj_size);
+ /* Subtraction of sizeof(zval) is necessary, because zend_object_properties_size() may be
+ * -sizeof(zval), if the object has no properties. */
+ memset(obj, 0, obj_size - sizeof(zval));
return obj;
}