com php-src: Avoid uninitialized entries in properties_info _table: Zend/zend_inheritance.c ext/opcache/zend_ persist.c

From: Date: Fri, 15 Feb 2019 13:43:37 +0000
Subject: com php-src: Avoid uninitialized entries in properties_info _table: Zend/zend_inheritance.c ext/opcache/zend_ persist.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104660@lists.php.net to get a copy of this message
Commit: e6e9bea25798068ff3c9135515e5d000fe70a43b Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 15 Feb 2019 13:42:37 +0100 Parents: fae22461f95dfe8153fb74a53b9c5daeec47387f Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e6e9bea25798068ff3c9135515e5d000fe70a43b Log: Avoid uninitialized entries in properties_info_table Also don't place it into xlat, there's only ever one user. Changed paths: M Zend/zend_inheritance.c M ext/opcache/zend_persist.c Diff: diff --git a/Zend/zend_inheritance..c b/Zend/zend_inheritance.c index 2ce4df3..67b8b84 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -855,19 +855,22 @@ static void do_inherit_class_constant(zend_string *name, zend_class_constant *pa void zend_build_properties_info_table(zend_class_entry *ce) { zend_property_info **table, *prop; + size_t size; if (ce->default_properties_count == 0) { return; } ZEND_ASSERT(ce->properties_info_table == NULL); + size = sizeof(zend_property_info *) * ce->default_properties_count; if (ce->type == ZEND_USER_CLASS) { - ce->properties_info_table = table = zend_arena_alloc(&CG(arena), - sizeof(zend_property_info *) * ce->default_properties_count); + ce->properties_info_table = table = zend_arena_alloc(&CG(arena), size); } else { - ce->properties_info_table = table = pemalloc( - sizeof(zend_property_info *) * ce->default_properties_count, 1); + ce->properties_info_table = table = pemalloc(size, 1); } + /* Dead slots may be left behind during inheritance. Make sure these are NULLed out. */ + memset(table, 0, size); + if (ce->parent && ce->parent->default_properties_count != 0) { zend_property_info **parent_table = ce->parent->properties_info_table; memcpy( diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 1a22f12..ed05872 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -860,16 +860,20 @@ static void zend_persist_class_entry(zval *zv) int i; size_t size = sizeof(zend_property_info *) * ce->default_properties_count; + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED); if (ZCG(is_immutable_class)) { - ce->properties_info_table = zend_shared_memdup_put( + ce->properties_info_table = zend_shared_memdup( ce->properties_info_table, size); } else { - ce->properties_info_table = zend_shared_memdup_arena_put( + ce->properties_info_table = zend_shared_memdup_arena( ce->properties_info_table, size); } for (i = 0; i < ce->default_properties_count; i++) { - ce->properties_info_table[i] = zend_shared_alloc_get_xlat_entry(ce->properties_info_table[i]); + if (ce->properties_info_table[i]) { + ce->properties_info_table[i] = zend_shared_alloc_get_xlat_entry( + ce->properties_info_table[i]); + } } }

« previous php.cvs (#104660) next »