From: Andi Gutmans Date: Wed, 16 Feb 2000 16:00:02 +0000 (+0000) Subject: - Hopefully fix Thies' bug report. X-Git-Tag: BEFORE_SAPI_POST_PATCH_17_FEB_2000~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b840c5f591d09b42141e1d795faae76b49832c5;p=php - Hopefully fix Thies' bug report. --- diff --git a/Zend/zend.h b/Zend/zend.h index b54940f2f2..449cdeda8d 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -324,13 +324,15 @@ END_EXTERN_C() ALLOC_ZVAL(zv); \ INIT_PZVAL(zv); +#define PZVAL_IS_REF(z) ((z)->is_ref) + #define SEPARATE_ZVAL(ppzv) \ { \ zval *orig_ptr = *(ppzv); \ \ if (orig_ptr->refcount>1) { \ orig_ptr->refcount--; \ - ALLOC_ZVAL(*(ppzv)); \ + ALLOC_ZVAL(*(ppzv)); \ **(ppzv) = *orig_ptr; \ zval_copy_ctor(*(ppzv)); \ (*(ppzv))->refcount=1; \ @@ -338,6 +340,12 @@ END_EXTERN_C() } \ } +#define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \ + if (!PZVAL_IS_REF(*ppzv)) { \ + SEPARATE_ZVAL(ppzv); \ + } + + #define COPY_PZVAL_TO_ZVAL(zv, pzv) \ (zv) = *(pzv); \ if ((pzv)->refcount>1) { \ diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index e7428bf019..f5cc994cd1 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -584,8 +584,6 @@ int zendlex(znode *zendlval CLS_DC); (ai).ptr = NULL; \ } -#define PZVAL_IS_REF(z) ((z)->is_ref) - /* Lost In Stupid Parentheses */ #define ARG_SHOULD_BE_SENT_BY_REF(offset, conduct_check, arg_types) \ ( \ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 700bf405c9..fd3715fc00 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -74,8 +74,8 @@ static void zend_extension_fcall_end_handler(zend_extension *extension, zend_op_ #define SEPARATE_ON_READ_OBJECT(obj, _type) \ -if ((obj) && ((_type) == BP_VAR_R) && ((*(obj))->type == IS_OBJECT) && (!(*(obj))->is_ref)) { \ - SEPARATE_ZVAL((obj)); \ +if ((obj) && ((_type) == BP_VAR_R) && ((*(obj))->type == IS_OBJECT)) { \ + SEPARATE_ZVAL_IF_NOT_REF((obj)); \ (*(obj))->is_ref = 1; \ } @@ -734,8 +734,8 @@ static inline void zend_fetch_dimension_address(znode *result, znode *op1, znode convert_to_long(&tmp); offset = &tmp; } - if (!container->is_ref && type!=BP_VAR_R && type!=BP_VAR_IS) { - SEPARATE_ZVAL(container_ptr); + if (type!=BP_VAR_R && type!=BP_VAR_IS) { + SEPARATE_ZVAL_IF_NOT_REF(container_ptr); } container = *container_ptr; Ts[result->u.var].EA.str = container; @@ -1249,7 +1249,7 @@ binary_assign_op_addr: { case ZEND_FETCH_UNSET: zend_fetch_var_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC); if (Ts[opline->result.u.var].var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL(Ts[opline->result.u.var].var.ptr_ptr); + SEPARATE_ZVAL_IF_NOT_REF(Ts[opline->result.u.var].var.ptr_ptr); } NEXT_OPCODE(); case ZEND_FETCH_IS: @@ -1291,7 +1291,7 @@ binary_assign_op_addr: { */ zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC); if (Ts[opline->result.u.var].var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL(Ts[opline->result.u.var].var.ptr_ptr); + SEPARATE_ZVAL_IF_NOT_REF(Ts[opline->result.u.var].var.ptr_ptr); } NEXT_OPCODE(); case ZEND_FETCH_OBJ_R: @@ -1320,7 +1320,7 @@ binary_assign_op_addr: { case ZEND_FETCH_OBJ_UNSET: zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, Ts, BP_VAR_R ELS_CC); if (Ts[opline->result.u.var].var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL(Ts[opline->result.u.var].var.ptr_ptr); + SEPARATE_ZVAL_IF_NOT_REF(Ts[opline->result.u.var].var.ptr_ptr); } NEXT_OPCODE(); case ZEND_FETCH_DIM_TMP_VAR: