From b4112ea288b41d1f26ae5248beb18bccb4ca9b2d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 16 Feb 2018 15:37:04 +0300 Subject: Don't make expectations about non-constant zval refcauntability --- Zend/zend_execute.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Zend/zend_execute.h') diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 21c8ed7b6b..5da2e2d9b1 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -92,10 +92,14 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval garbage = Z_COUNTED_P(variable_ptr); if (GC_DELREF(garbage) == 0) { ZVAL_COPY_VALUE(variable_ptr, value); - if (value_type & (IS_CONST|IS_CV)) { + if (ZEND_CONST_COND(value_type == IS_CONST, 0)) { if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) { Z_ADDREF_P(variable_ptr); } + } else if (value_type & (IS_CONST|IS_CV)) { + if (Z_OPT_REFCOUNTED_P(variable_ptr)) { + Z_ADDREF_P(variable_ptr); + } } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); @@ -115,10 +119,14 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval } while (0); ZVAL_COPY_VALUE(variable_ptr, value); - if (value_type & (IS_CONST|IS_CV)) { + if (ZEND_CONST_COND(value_type == IS_CONST, 0)) { if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) { Z_ADDREF_P(variable_ptr); } + } else if (value_type & (IS_CONST|IS_CV)) { + if (Z_OPT_REFCOUNTED_P(variable_ptr)) { + Z_ADDREF_P(variable_ptr); + } } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) { if (UNEXPECTED(GC_DELREF(ref) == 0)) { efree_size(ref, sizeof(zend_reference)); -- cgit v1.2.1