com php-src: Fixed bug #80290: NEWS ext/standard/assert.c ext/standard/tests/assert/bug80290.phpt
| From: | Nikita Popov | Date: | Fri, 30 Oct 2020 10:13:35 +0000 |
| Subject: | com php-src: Fixed bug #80290: NEWS ext/standard/assert.c ext/standard/tests/assert/bug80290.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-113993@lists.php.net to get a copy of this message | ||
Commit: 3bd3651bcc3d374586b291195d1b3471f3f7287d
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 30 Oct 2020 11:11:16 +0100
Parents: b133183e35d3fb07052b9dc1b7bbcf4354611ba0
Branches: PHP-8.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3bd3651bcc3d374586b291195d1b3471f3f7287d
Log:
Fixed bug #80290
Dropping the dtor arg args[3] rather than using STR_COPY: Since
PHP 8, we no longer support separation in call_user_function(),
so we also don't need to worry about things like arguments being
replaced with references.
Bugs:
https://bugs.php.net/80290
Changed paths:
M NEWS
M ext/standard/assert.c
A ext/standard/tests/assert/bug80290.phpt
Diff:
diff --git a/NEWS b/NEWS
index 23c9ff8638f..0884c32f3fc 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ PHP NEWS
- Standard:
. Don't force rebuild of symbol table, when populating $http_response_header
variable by the HTTP stream wrapper. (Dmitry)
+ . Fixed bug #80290 (Double free when ASSERT_CALLBACK is used with a dynamic
+ message).. (Nikita)
29 Oct 2020, PHP 8.0.0RC3
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index 382c0b87e46..86acaec3898 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -181,15 +181,11 @@ PHP_FUNCTION(assert)
if (description_str) {
ZVAL_STR(&args[3], description_str);
call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 4, args);
- zval_ptr_dtor(&(args[3]));
- zval_ptr_dtor(&(args[2]));
- zval_ptr_dtor(&(args[0]));
} else {
call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 3, args);
- zval_ptr_dtor(&(args[2]));
- zval_ptr_dtor(&(args[0]));
}
+ zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&retval);
}
diff --git a/ext/standard/tests/assert/bug80290.phpt b/ext/standard/tests/assert/bug80290..phpt
new file mode 100644
index 00000000000..ef345fd1934
--- /dev/null
+++ b/ext/standard/tests/assert/bug80290.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #80290: Double free when ASSERT_CALLBACK is used with a dynamic message
+--FILE--
+<?php
+
+assert_options(ASSERT_CALLBACK, function($file, $line, $unused, $message) {
+ var_dump($message);
+});
+
+$x = 'x';
+assert(false, 'Dynamic message: ' . $x);
+
+?>
+--EXPECTF--
+string(18) "Dynamic message: x"
+
+Fatal error: Uncaught AssertionError: Dynamic message: x in %s:%d
+Stack trace:
+#0 %s(%d): assert(false, 'Dynamic message...')
+#1 {main}
+ thrown in %s on line %d