From: Nikita Popov Date: Wed, 4 Nov 2020 13:51:44 +0000 (+0100) Subject: Assert that references are not persisted X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7794925ba4d7510f4afc5d5a83358aa4106bf189;p=php Assert that references are not persisted There should not be any need to persist references, and it's unlikely that persisting a reference will behave correctly at runtime, because we don't have a concept of an immutable reference. --- diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 77d67851b4..efadcb91fb 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -230,15 +230,6 @@ static void zend_persist_zval(zval *z) } } break; - case IS_REFERENCE: - new_ptr = zend_shared_alloc_get_xlat_entry(Z_REF_P(z)); - if (new_ptr) { - Z_REF_P(z) = new_ptr; - } else { - Z_REF_P(z) = zend_shared_memdup_put_free(Z_REF_P(z), sizeof(zend_reference)); - zend_persist_zval(Z_REFVAL_P(z)); - } - break; case IS_CONSTANT_AST: new_ptr = zend_shared_alloc_get_xlat_entry(Z_AST_P(z)); if (new_ptr) { @@ -254,8 +245,7 @@ static void zend_persist_zval(zval *z) } break; default: - ZEND_ASSERT(Z_TYPE_P(z) != IS_OBJECT); - ZEND_ASSERT(Z_TYPE_P(z) != IS_RESOURCE); + ZEND_ASSERT(Z_TYPE_P(z) < IS_STRING); break; } } diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 4a612751a6..9de02e91e2 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -128,13 +128,6 @@ static void zend_persist_zval_calc(zval *z) } ZEND_HASH_FOREACH_END(); } break; - case IS_REFERENCE: - size = zend_shared_memdup_size(Z_REF_P(z), sizeof(zend_reference)); - if (size) { - ADD_SIZE(size); - zend_persist_zval_calc(Z_REFVAL_P(z)); - } - break; case IS_CONSTANT_AST: size = zend_shared_memdup_size(Z_AST_P(z), sizeof(zend_ast_ref)); if (size) { @@ -143,8 +136,7 @@ static void zend_persist_zval_calc(zval *z) } break; default: - ZEND_ASSERT(Z_TYPE_P(z) != IS_OBJECT); - ZEND_ASSERT(Z_TYPE_P(z) != IS_RESOURCE); + ZEND_ASSERT(Z_TYPE_P(z) < IS_STRING); break; } }