cvs: ZendEngine2 / zend_execute.c /tests bug48004.phpt

"Dmitry Stogov" <[email protected]> Tue, 21 Apr 2009 08:12:23 -0000
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsdmitry1240301543@cvsserver>
dmitry		Tue Apr 21 08:12:23 2009 UTC

  Modified files:              
    /ZendEngine2	zend_execute.c 
    /ZendEngine2/tests	bug48004.phpt 
  Log:
  Fixed bug #48004 (Error handler prevents creation of default object)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.811&r2=1.812&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.811 ZendEngine2/zend_execute.c:1.812
--- ZendEngine2/zend_execute.c:1.811	Thu Mar 26 20:01:38 2009
+++ ZendEngine2/zend_execute.c	Tue Apr 21 08:12:23 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c,v 1.811 2009/03/26 20:01:38 felipe Exp $ */
+/* $Id: zend_execute.c,v 1.812 2009/04/21 08:12:23 dmitry Exp $ */
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -559,13 +559,13 @@
 
 static inline void zend_assign_to_object(znode *result, zval **object_ptr, zval *property_name, znode *value_op, const temp_variable *Ts, int opcode TSRMLS_DC) /* {{{ */
 {
-	zval *object;
+	zval *object = *object_ptr;
 	zend_free_op free_value;
 	zval *value = get_zval_ptr(value_op, Ts, &free_value, BP_VAR_R);
 	zval **retval = &T(result->u.var).var.ptr;
 
-	if (Z_TYPE_P(*object_ptr) != IS_OBJECT) {
-		if (*object_ptr == EG(error_zval_ptr)) {
+	if (Z_TYPE_P(object) != IS_OBJECT) {
+		if (object == EG(error_zval_ptr)) {
 			if (!RETURN_VALUE_UNUSED(result)) {
 				*retval = EG(uninitialized_zval_ptr);
 				PZVAL_LOCK(*retval);
@@ -573,14 +573,15 @@
 			FREE_OP(free_value);
 			return;
 		}
-		if (Z_TYPE_PP(object_ptr) == IS_NULL ||
-		    (Z_TYPE_PP(object_ptr) == IS_BOOL && Z_LVAL_PP(object_ptr) == 0) ||
-		    (Z_TYPE_PP(object_ptr) == IS_STRING && Z_STRLEN_PP(object_ptr) == 0) ||
-		    (Z_TYPE_PP(object_ptr) == IS_UNICODE && Z_USTRLEN_PP(object_ptr) == 0)) {
-			zend_error(E_STRICT, "Creating default object from empty value");
+		if (Z_TYPE_P(object) == IS_NULL ||
+		    (Z_TYPE_P(object) == IS_BOOL && Z_LVAL_P(object) == 0) ||
+		    (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0) ||
+		    (Z_TYPE_P(object) == IS_UNICODE && Z_USTRLEN_P(object) == 0)) {
 			SEPARATE_ZVAL_IF_NOT_REF(object_ptr);
-			zval_dtor(*object_ptr);
-			object_init(*object_ptr);
+			zval_dtor(object);
+			object = *object_ptr;
+			object_init(object);
+			zend_error(E_STRICT, "Creating default object from empty value");
 		} else {
 			zend_error(E_WARNING, "Attempt to assign property of non-object");
 			if (!RETURN_VALUE_UNUSED(result)) {
@@ -593,7 +594,6 @@
 	}
 
  	/* here we are sure we are dealing with an object */
- 	object = *object_ptr;
 
 	/* separate our value if necessary */
 	if (value_op->op_type == IS_TMP_VAR) {
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug48004.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug48004.phpt
diff -u /dev/null ZendEngine2/tests/bug48004.phpt:1.2
--- /dev/null	Tue Apr 21 08:12:23 2009
+++ ZendEngine2/tests/bug48004.phpt	Tue Apr 21 08:12:23 2009
@@ -0,0 +1,21 @@
+--TEST--
+Bug #48004 (Error handler prevents creation of default object)
+--FILE--
+<?php
+function error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
+        return true;
+}
+
+function test() {
+        $data->id = 1;
+        print_r($data);
+}
+
+set_error_handler("error_handler");
+test();
+?>
+--EXPECT--
+stdClass Object
+(
+    [id] => 1
+)



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php