cvs: ZendEngine2(PHP_5_0) / zend.h zend_object_handlers.c /tests bug31683.phpt php-src NEWS

From: Date: Wed, 02 Feb 2005 07:19:02 +0000
Subject: cvs: ZendEngine2(PHP_5_0) / zend.h zend_object_handlers.c /tests bug31683.phpt php-src NEWS
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3355@lists.php.net to get a copy of this message
dmitry Wed Feb 2 02:19:02 2005 EDT Added files: (Branch: PHP_5_0) /ZendEngine2/tests bug31683.phpt Modified files: /php-src NEWS /ZendEngine2 zend.h zend_object_handlers.c Log: Fixed bugs #29767 and #31683 (__get and __set methods must not modify property name). http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.225&r2=1.1760.2.226&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1760.2.225 php-src/NEWS:1.1760.2.226 --- php-src/NEWS:1.1760.2.225 Tue Feb 1 18:28:30 2005 +++ php-src/NEWS Wed Feb 2 02:19:01 2005 @@ -23,6 +23,8 @@ - Fixed bug #31705 (parse_url() does not recognize http://foo.com#bar). (Ilia) - Fixed bug #31684 (dio_tcsetattr(): misconfigured termios settings). (elod at itfais dot com) +- Fixed bug #31683 (changes to $name in __get($name) override future + parameters). (Dmitry) - Fixed bug #31699 (unserialize() float problem on non-English locales). (Ilia) - Fixed bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays). (Marcus) @@ -72,6 +74,7 @@ in segfault). (pdan-php at esync dot org, Tony) - Fixed bug #30120 (imagettftext() and imagettfbbox() accept too many parameters). (Jani) +- Fixed bug #29767 (Weird behaviour of __set($name, $value)). (Dmitry) - Fixed bug #29733 (printf() handles repeated placeholders wrong). (bugs dot php dot net at bluetwanger dot de, Ilia) - Fixed bug #29136 (make test - libtool failure on MacOSX). (Jani) http://cvs.php.net/diff.php/ZendEngine2/zend.h?r1=1.257.2.21&r2=1.257.2.22&ty=u Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.257.2.21 ZendEngine2/zend.h:1.257.2.22 --- ZendEngine2/zend.h:1.257.2.21 Tue Jan 25 08:08:26 2005 +++ ZendEngine2/zend.h Wed Feb 2 02:19:02 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.257.2.21 2005/01/25 13:08:26 sniper Exp $ */ +/* $Id: zend.h,v 1.257.2.22 2005/02/02 07:19:02 dmitry Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -603,6 +603,20 @@ (*ppzv_dest)->refcount = refcount; \ } +#define SEPARATE_ARG_IF_REF(varptr) \ + if (PZVAL_IS_REF(varptr)) { \ + zval *original_var = varptr; \ + ALLOC_ZVAL(varptr); \ + varptr->value = original_var->value; \ + varptr->type = original_var->type; \ + varptr->is_ref = 0; \ + varptr->refcount = 1; \ + zval_copy_ctor(varptr); \ + } else { \ + varptr->refcount++; \ + } + + #define ZEND_MAX_RESERVED_RESOURCES 4 http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.101.2.4&r2=1.101.2.5&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.101.2.4 ZendEngine2/zend_object_handlers.c:1.101.2.5 --- ZendEngine2/zend_object_handlers.c:1.101.2.4 Tue Jan 18 20:46:47 2005 +++ ZendEngine2/zend_object_handlers.c Wed Feb 2 02:19:02 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.101.2.4 2005/01/19 01:46:47 sniper Exp $ */ +/* $Id: zend_object_handlers.c,v 1.101.2.5 2005/02/02 07:19:02 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -72,6 +72,7 @@ INIT_PZVAL(&__get_name); ZVAL_STRINGL(&__get_name, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)-1, 0); + SEPARATE_ARG_IF_REF(member); call_args[0] = &member; /* go call the __get handler */ @@ -87,11 +88,13 @@ retval returns the value that is received */ - if (call_result == FAILURE) { zend_error(E_ERROR, "Could not call __get handler for class %s", Z_OBJCE_P(object)->name); return NULL; } + + zval_ptr_dtor(&member); + if (retval) { retval->refcount--; } @@ -116,6 +119,7 @@ INIT_PZVAL(&__set_name); ZVAL_STRINGL(&__set_name, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)-1, 0); + SEPARATE_ARG_IF_REF(member); call_args[0] = &member; value->refcount++; call_args[1] = &value; @@ -139,6 +143,7 @@ return FAILURE; } + zval_ptr_dtor(&member); zval_ptr_dtor(&value); if (retval && zend_is_true(retval)) { @@ -383,12 +388,14 @@ if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { if(offset == NULL) { /* [] construct */ - zval offset_null; - INIT_ZVAL(offset_null); - offset = &offset_null; + ALLOC_INIT_ZVAL(offset); + } else { + SEPARATE_ARG_IF_REF(offset); } zend_call_method_with_1_params(&object, ce, NULL, "offsetget", &retval, offset); + zval_ptr_dtor(&offset); + if (!retval) { if (!EG(exception)) { zend_error(E_ERROR, "Undefined offset for object of type %s used as array", ce->name); @@ -410,14 +417,15 @@ static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) { zend_class_entry *ce = Z_OBJCE_P(object); - zval tmp; if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { if (!offset) { - INIT_ZVAL(tmp); - offset = &tmp; + ALLOC_INIT_ZVAL(offset); + } else { + SEPARATE_ARG_IF_REF(offset); } zend_call_method_with_2_params(&object, ce, NULL, "offsetset", NULL, offset, value); + zval_ptr_dtor(&offset); } else { zend_error(E_ERROR, "Cannot use object of type %s as array", ce->name); } @@ -431,7 +439,9 @@ int result; if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { + SEPARATE_ARG_IF_REF(offset); zend_call_method_with_1_params(&object, ce, NULL, "offsetexists", &retval, offset); + zval_ptr_dtor(&offset); result = i_zend_is_true(retval); zval_ptr_dtor(&retval); return result; @@ -516,7 +526,9 @@ zval *retval; if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { + SEPARATE_ARG_IF_REF(offset); zend_call_method_with_1_params(&object, ce, NULL, "offsetunset", &retval, offset); + zval_ptr_dtor(&offset); zval_ptr_dtor(&retval); } else { zend_error(E_ERROR, "Cannot use object of type %s as array", ce->name); http://cvs.php.net/co.php/ZendEngine2/tests/bug31683.phpt?r=1.1&p=1 Index: ZendEngine2/tests/bug31683.phpt +++ ZendEngine2/tests/bug31683.phpt

« previous php.zend-engine.cvs (#3355) next »