Skip to content

Commit da4d5e9

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed bug #80290
2 parents fab8ef6 + 3bd3651 commit da4d5e9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

ext/standard/assert.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,11 @@ PHP_FUNCTION(assert)
181181
if (description_str) {
182182
ZVAL_STR(&args[3], description_str);
183183
call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 4, args);
184-
zval_ptr_dtor(&(args[3]));
185-
zval_ptr_dtor(&(args[2]));
186-
zval_ptr_dtor(&(args[0]));
187184
} else {
188185
call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 3, args);
189-
zval_ptr_dtor(&(args[2]));
190-
zval_ptr_dtor(&(args[0]));
191186
}
192187

188+
zval_ptr_dtor(&args[0]);
193189
zval_ptr_dtor(&retval);
194190
}
195191

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #80290: Double free when ASSERT_CALLBACK is used with a dynamic message
3+
--FILE--
4+
<?php
5+
6+
assert_options(ASSERT_CALLBACK, function($file, $line, $unused, $message) {
7+
var_dump($message);
8+
});
9+
10+
$x = 'x';
11+
assert(false, 'Dynamic message: ' . $x);
12+
13+
?>
14+
--EXPECTF--
15+
string(18) "Dynamic message: x"
16+
17+
Fatal error: Uncaught AssertionError: Dynamic message: x in %s:%d
18+
Stack trace:
19+
#0 %s(%d): assert(false, 'Dynamic message...')
20+
#1 {main}
21+
thrown in %s on line %d

0 commit comments

Comments
 (0)