Skip to content

Commit 4daa413

Browse files
committed
Fixed bug #77092
Weird that this worked for so long, probably because nearly all ext/standard functions use fast ZPP rather than ordinary ZPP.
1 parent 10255a0 commit 4daa413

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88

99
- Opcache:
1010
. Fixed bug #77058 (Type inference in opcache causes side effects). (Nikita)
11+
. Fixed bug #77092 (array_diff_key() - segmentation fault). (Nikita)
1112

1213
- SOAP:
1314
. Fixed bug #50675 (SoapClient can't handle object references correctly).

ext/opcache/Optimizer/sccp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ static inline int ct_eval_in_array(zval *result, uint32_t extended_value, zval *
585585
static inline int ct_eval_func_call(
586586
zval *result, zend_string *name, uint32_t num_args, zval **args) {
587587
uint32_t i;
588-
zend_execute_data *execute_data;
588+
zend_execute_data *execute_data, *prev_execute_data;
589589
zend_function *func;
590590
int overflow;
591591

@@ -840,6 +840,9 @@ static inline int ct_eval_func_call(
840840

841841
execute_data = safe_emalloc(num_args, sizeof(zval), ZEND_CALL_FRAME_SLOT * sizeof(zval));
842842
memset(execute_data, 0, sizeof(zend_execute_data));
843+
prev_execute_data = EG(current_execute_data);
844+
EG(current_execute_data) = execute_data;
845+
843846
EX(func) = func;
844847
EX_NUM_ARGS() = num_args;
845848
for (i = 0; i < num_args; i++) {
@@ -850,6 +853,7 @@ static inline int ct_eval_func_call(
850853
zval_ptr_dtor_nogc(EX_VAR_NUM(i));
851854
}
852855
efree(execute_data);
856+
EG(current_execute_data) = prev_execute_data;
853857
return SUCCESS;
854858
}
855859

ext/opcache/tests/bug77092.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #77092: array_diff_key() - segmentation fault
3+
--INI--
4+
opcache.enable_cli=1
5+
opcache.optimization_level=-1
6+
--FILE--
7+
<?php
8+
function test() {
9+
$anyArrayOne = ['foo' => 'bar', 'bar' => 'baz'];
10+
$anyArrayTwo = ['foo' => null];
11+
12+
print_r(array_diff_key($anyArrayOne, $anyArrayTwo));
13+
}
14+
test();
15+
?>
16+
--EXPECT--
17+
Array
18+
(
19+
[bar] => baz
20+
)

0 commit comments

Comments
 (0)