File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ PHP NEWS
69
69
- SPL:
70
70
. Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
71
71
72
+ - Standard:
73
+ . Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with
74
+ bail enabled). (ilutov)
75
+
72
76
- XMLReader:
73
77
. Fixed bug GH-16292 (Segmentation fault in ext/xmlreader/php_xmlreader.c).
74
78
(nielsdos)
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16293: Exception in assert() callback with bail enabled
3
+ --FILE--
4
+ <?php
5
+
6
+ assert_options (ASSERT_EXCEPTION , 0 );
7
+ assert_options (ASSERT_BAIL , 1 );
8
+ assert_options (ASSERT_CALLBACK , 'f1 ' );
9
+ assert (false );
10
+
11
+ ?>
12
+ --EXPECTF--
13
+ Warning: assert(): assert(false) failed in %s on line %d
14
+
15
+ Warning: Uncaught Error: Invalid callback f1, function "f1" not found or invalid function name in %s:%d
16
+ Stack trace:
17
+ #0 %s(%d): assert(false, 'assert(false)')
18
+ #1 {main}
19
+ thrown in %s on line %d
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16293: Exception in assert() callback with bail enabled
3
+ --FILE--
4
+ <?php
5
+
6
+ assert_options (ASSERT_EXCEPTION , 0 );
7
+ assert_options (ASSERT_BAIL , 1 );
8
+ assert_options (ASSERT_CALLBACK , function () {
9
+ throw new Exception ('Boo ' );
10
+ });
11
+ assert (false );
12
+
13
+ ?>
14
+ --EXPECTF--
15
+ Warning: assert(): assert(false) failed in %s on line %d
16
+
17
+ Warning: Uncaught Exception: Boo in %s:%d
18
+ Stack trace:
19
+ %a
Original file line number Diff line number Diff line change @@ -238,6 +238,11 @@ PHP_FUNCTION(assert)
238
238
}
239
239
240
240
if (ASSERTG (bail )) {
241
+ if (EG (exception )) {
242
+ /* The callback might have thrown. Use E_WARNING to print the
243
+ * exception so we can avoid bailout and use unwind_exit. */
244
+ zend_exception_error (EG (exception ), E_WARNING );
245
+ }
241
246
zend_throw_unwind_exit ();
242
247
RETURN_THROWS ();
243
248
} else {
You can’t perform that action at this time.
0 commit comments