com php-src: Fixed bug #70547 (unsetting function variables corrupts backtrace): NEWS Zend/tests/bug70547.phpt Zend/zend_builtin _functions.c
| From: | Xinchen Hui | Date: | Tue, 22 Sep 2015 03:59:35 +0000 |
| Subject: | com php-src: Fixed bug #70547 (unsetting function variables corrupts backtrace): NEWS Zend/tests/bug70547.phpt Zend/zend_builtin _functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89097@lists.php.net to get a copy of this message | ||
Commit: e1dcfd2cf900995fba28866dfb52fa68171d1ab8
Author: Xinchen Hui <laruence@gmail.com> Tue, 22 Sep 2015 11:59:35 +0800
Parents: ed5a5bdff88fcbab6208ea396efd6808e00de573
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e1dcfd2cf900995fba28866dfb52fa68171d1ab8
Log:
Fixed bug #70547 (unsetting function variables corrupts backtrace)
Bugs:
https://bugs.php.net/70547
Changed paths:
M NEWS
A Zend/tests/bug70547.phpt
M Zend/zend_builtin_functions.c
Diff:
diff --git a/NEWS b/NEWS
index 3d8abc9..dec9a66 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
01 Oct 2015, PHP 7.0.0 RC 4
- Core:
+ . Fixed bug #70547 (unsetting function variables corrupts backtrace).
+ (Laruence)
. Fixed bug #70528 (assert() with instanceof adds apostrophes around class
name). (Laruence)
. Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build).
diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt
new file mode 100644
index 0000000..195495d
--- /dev/null
+++ b/Zend/tests/bug70547.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug #70547 (unsetting function variables corrupts backtrace)
+--FILE--
+<?php
+function brokenTrace($arg1, $arg2, $arg3){
+ backtraceWrapper();
+ unset($arg3);
+ backtraceWrapper();
+ unset($arg1);
+ backtraceWrapper();
+ unset($arg2);
+ backtraceWrapper();
+}
+brokenTrace("1st", "2nd", "3th", "4th");
+function backtraceWrapper(){
+ $bt = debug_backtrace();
+ var_dump($bt[1]['args']);
+}
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ string(3) "1st"
+ [1]=>
+ string(3) "2nd"
+ [2]=>
+ string(3) "3th"
+ [3]=>
+ string(3) "4th"
+}
+array(3) {
+ [0]=>
+ string(3) "1st"
+ [1]=>
+ string(3) "2nd"
+ [2]=>
+ string(3) "4th"
+}
+array(2) {
+ [0]=>
+ string(3) "2nd"
+ [1]=>
+ string(3) "4th"
+}
+array(1) {
+ [0]=>
+ string(3) "4th"
+}
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index e3f087b..b0e4f6a 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -2233,8 +2233,12 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval
*arg_array) /
if (ZEND_CALL_NUM_ARGS(call) > first_extra_arg) {
while (i < first_extra_arg) {
- if (Z_OPT_REFCOUNTED_P(p)) Z_ADDREF_P(p);
- ZEND_HASH_FILL_ADD(p);
+ if (Z_TYPE_INFO_P(p) != IS_UNDEF) {
+ if (Z_OPT_REFCOUNTED_P(p)) {
+ Z_ADDREF_P(p);
+ }
+ ZEND_HASH_FILL_ADD(p);
+ }
p++;
i++;
}
@@ -2243,8 +2247,12 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval
*arg_array) /
}
while (i < num_args) {
- if (Z_OPT_REFCOUNTED_P(p)) Z_ADDREF_P(p);
- ZEND_HASH_FILL_ADD(p);
+ if (Z_TYPE_INFO_P(p) != IS_UNDEF) {
+ if (Z_OPT_REFCOUNTED_P(p)) {
+ Z_ADDREF_P(p);
+ }
+ ZEND_HASH_FILL_ADD(p);
+ }
p++;
i++;
}