Last active
December 11, 2019 08:58
-
-
Save dstogov/d119dde4bdce20d6cb3c8681946f79cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_API.c b/Zend/zend_API.c | |
index 3493a241a6..21d2c964e8 100644 | |
--- a/Zend/zend_API.c | |
+++ b/Zend/zend_API.c | |
@@ -2762,6 +2762,7 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or | |
ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent) /* {{{ */ | |
{ | |
zend_string *lcname; | |
+ zval zv, *ret; | |
/* TODO: Move this out of here in 7.4. */ | |
if (persistent && EG(current_module) && EG(current_module)->type == MODULE_TEMPORARY) { | |
@@ -2779,9 +2780,11 @@ ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zen | |
zend_assert_valid_class_name(lcname); | |
lcname = zend_new_interned_string(lcname); | |
- ce = zend_hash_add_ptr(CG(class_table), lcname, ce); | |
+ | |
+ ZVAL_ALIAS_PTR(&zv, ce); | |
+ ret = zend_hash_add(CG(class_table), lcname, &zv); | |
zend_string_release_ex(lcname, 0); | |
- if (ce) { | |
+ if (ret) { | |
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) { | |
ce->refcount++; | |
} | |
diff --git a/Zend/zend_types.h b/Zend/zend_types.h | |
index 50634417c6..7b8c079c45 100644 | |
--- a/Zend/zend_types.h | |
+++ b/Zend/zend_types.h | |
@@ -427,6 +427,7 @@ struct _zend_ast_ref { | |
/* internal types */ | |
#define IS_INDIRECT 13 | |
#define IS_PTR 14 | |
+#define IS_ALIAS_PTR 15 | |
#define _IS_ERROR 15 | |
/* fake types used only for type hinting (Z_TYPE(zv) can not use them) */ | |
@@ -964,6 +965,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { | |
Z_TYPE_INFO_P(z) = IS_PTR; \ | |
} while (0) | |
+#define ZVAL_ALIAS_PTR(z, p) do { \ | |
+ Z_PTR_P(z) = (p); \ | |
+ Z_TYPE_INFO_P(z) = IS_ALIAS_PTR; \ | |
+ } while (0) | |
+ | |
#define ZVAL_ERROR(z) do { \ | |
Z_TYPE_INFO_P(z) = _IS_ERROR; \ | |
} while (0) | |
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c | |
index 055ab1bd25..5f45c3ff37 100644 | |
--- a/ext/opcache/ZendAccelerator.c | |
+++ b/ext/opcache/ZendAccelerator.c | |
@@ -3259,7 +3259,7 @@ static void preload_move_user_classes(HashTable *src, HashTable *dst) | |
} | |
} | |
if (copy) { | |
- _zend_hash_append_ptr(dst, p->key, ce); | |
+ _zend_hash_append(dst, p->key, &p->val); | |
} else { | |
orig_dtor(&p->val); | |
} | |
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c | |
index bcbd2f270f..06d103d670 100644 | |
--- a/ext/opcache/zend_persist.c | |
+++ b/ext/opcache/zend_persist.c | |
@@ -1037,8 +1037,11 @@ static void zend_accel_persist_class_table(HashTable *class_table) | |
zend_accel_store_interned_string(p->key); | |
zend_persist_class_entry(&p->val); | |
} ZEND_HASH_FOREACH_END(); | |
- ZEND_HASH_FOREACH_PTR(class_table, ce) { | |
- zend_update_parent_ce(ce); | |
+ ZEND_HASH_FOREACH_BUCKET(class_table, p) { | |
+ if (EXPECTED(Z_TYPE(p->val) != IS_ALIAS_PTR)) { | |
+ ce = Z_PTR(p->val); | |
+ zend_update_parent_ce(ce); | |
+ } | |
} ZEND_HASH_FOREACH_END(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment