1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Subtract one zval from memset

This commit is contained in:
Nikita Popov
2017-11-25 18:02:01 +01:00
parent b72b1a4e4d
commit 721f2cc513

View File

@@ -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;
}