Skip to content

Commit 4c38a79

Browse files
committed
Fix incorrect CG(memoize_mode) state after bailout in ??=
Fixes GH-11108 Closes GH-11109
1 parent 5855bdc commit 4c38a79

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ PHP NEWS
1111
. Fixed bug GH-10737 (PHP 8.1.16 segfaults on line 597 of
1212
sapi/apache2handler/sapi_apache2.c). (nielsdos, ElliotNB)
1313
. Fixed bug GH-11028 (Heap Buffer Overflow in zval_undefined_cv.). (nielsdos)
14+
. Fixed bug GH-11108 (Incorrect CG(memoize_mode) state after bailout in ??=).
15+
(ilutov)
1416

1517
- DOM:
1618
. Fixed bug #80602 (Segfault when using DOMChildNode::before()).

Zend/tests/gh11108.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-11108: Incorrect CG(memoize_mode) state after bailout in ??=
3+
--FILE--
4+
<?php
5+
register_shutdown_function(function() {
6+
include __DIR__ . '/gh11108_shutdown.inc';
7+
});
8+
include __DIR__ . '/gh11108_test.inc';
9+
?>
10+
--EXPECTF--
11+
Fatal error: Cannot use [] for reading in %s on line %d

Zend/tests/gh11108_shutdown.inc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
function test() {
4+
throw new Exception();
5+
}

Zend/tests/gh11108_test.inc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$messageList[] ??= true;

Zend/zend.c

+1
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,7 @@ ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32
11921192
CG(unclean_shutdown) = 1;
11931193
CG(active_class_entry) = NULL;
11941194
CG(in_compilation) = 0;
1195+
CG(memoize_mode) = 0;
11951196
EG(current_execute_data) = NULL;
11961197
LONGJMP(*EG(bailout), FAILURE);
11971198
}

0 commit comments

Comments
 (0)