summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2005-02-10 11:45:24 +0000
committerDmitry Stogov <dmitry@php.net>2005-02-10 11:45:24 +0000
commit5764d6f41bdf6041660f08d14be15e97e6026cdb (patch)
treecc14119f9b08e7fddddba67216b2af293e0edc2b
parent877a2bd690eaa965468de908327d8d0d457a50ed (diff)
downloadphp-git-5764d6f41bdf6041660f08d14be15e97e6026cdb.tar.gz
Fixed bug #30407 (Strange behaviour of default arguments)
-rw-r--r--NEWS1
-rw-r--r--Zend/tests/bug30407.phpt18
-rw-r--r--Zend/zend_vm_def.h5
-rw-r--r--Zend/zend_vm_execute.h10
4 files changed, 28 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 71372b8512..157c336c17 100644
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,7 @@ PHP NEWS
- Fixed bug in mysql::client_version(). (Georg)
- Fixed ZTS destruction. (Marcus)
- Fixed bug #31478 (segfault with empty() / isset()). (Moriyoshi)
+- Fixed bug #30407 (Strange behaviour of default arguments). (Dmitry)
- Fixed bug #29728 (Reflection API Feature: Default parameter value). (Marcus)
- Fixed bug #29522 (accessing properties without connection). (Georg)
- Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default). (Georg)
diff --git a/Zend/tests/bug30407.phpt b/Zend/tests/bug30407.phpt
new file mode 100644
index 0000000000..6dcc6b3481
--- /dev/null
+++ b/Zend/tests/bug30407.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #30407 (Strange behaviour of default arguments)
+--FILE--
+<?php
+
+function haricow($a = 'one') {
+ var_dump($a);
+ $a = 'two';
+}
+
+haricow();
+haricow();
+?>
+===DONE===
+--EXPECT--
+string(3) "one"
+string(3) "one"
+===DONE===
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 31c41658ba..ad6c7e4774 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -2197,7 +2197,6 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
zval **param, *assignment_value;
zend_uint arg_num = opline->op1.u.constant.value.lval;
zend_free_op free_res;
- zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
if (zend_ptr_stack_get_arg(arg_num, (void **) &param TSRMLS_CC)==FAILURE) {
if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) {
@@ -2219,8 +2218,10 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
assignment_value = &opline->op2.u.constant;
}
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC);
- zend_receive(var_ptr, assignment_value TSRMLS_CC);
+ zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC);
} else {
+ zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
+
assignment_value = *param;
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC);
if (PZVAL_IS_REF(assignment_value)) {
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 29d5101c0a..ab53117ca7 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -638,7 +638,6 @@ static int ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval **param, *assignment_value;
zend_uint arg_num = opline->op1.u.constant.value.lval;
zend_free_op free_res;
- zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
if (zend_ptr_stack_get_arg(arg_num, (void **) &param TSRMLS_CC)==FAILURE) {
if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) {
@@ -660,8 +659,10 @@ static int ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
assignment_value = &opline->op2.u.constant;
}
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC);
- zend_receive(var_ptr, assignment_value TSRMLS_CC);
+ zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC);
} else {
+ zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
+
assignment_value = *param;
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC);
if (PZVAL_IS_REF(assignment_value)) {
@@ -29910,7 +29911,6 @@ static int ZEND_RECV_INIT_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
zval **param, *assignment_value;
zend_uint arg_num = opline->op1.u.constant.value.lval;
zend_free_op free_res;
- zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
if (zend_ptr_stack_get_arg(arg_num, (void **) &param TSRMLS_CC)==FAILURE) {
if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) {
@@ -29932,8 +29932,10 @@ static int ZEND_RECV_INIT_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
assignment_value = &opline->op2.u.constant;
}
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC);
- zend_receive(var_ptr, assignment_value TSRMLS_CC);
+ zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC);
} else {
+ zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
+
assignment_value = *param;
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC);
if (PZVAL_IS_REF(assignment_value)) {