File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -2438,7 +2438,12 @@ PHP_FUNCTION(preg_replace_callback_array)
2438
2438
}
2439
2439
2440
2440
if (subject_ht ) {
2441
- RETURN_ARR (subject_ht );
2441
+ RETVAL_ARR (subject_ht );
2442
+ // Unset the type_flags of immutable arrays to prevent the VM from performing refcounting
2443
+ if (GC_FLAGS (subject_ht ) & IS_ARRAY_IMMUTABLE ) {
2444
+ Z_TYPE_FLAGS_P (return_value ) = 0 ;
2445
+ }
2446
+ return ;
2442
2447
} else {
2443
2448
RETURN_STR (subject_str );
2444
2449
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-10968: preg_replace_callback_array() segmentation fault
3
+ --FILE--
4
+ <?php
5
+ var_dump (preg_replace_callback_array ([], []));
6
+ var_dump (preg_replace_callback_array ([], '' ));
7
+ ?>
8
+ --EXPECT--
9
+ array(0) {
10
+ }
11
+ string(0) ""
You can’t perform that action at this time.
0 commit comments