Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/Optimizer/zend_optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array,
case ZEND_SWITCH_LONG:
case ZEND_SWITCH_STRING:
case ZEND_MATCH:
case ZEND_MATCH_ERROR:
case ZEND_JMP_NULL: {
zend_op *end = op_array->opcodes + op_array->last;
while (opline < end) {
Expand All @@ -652,6 +653,7 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array,
&& opline->opcode != ZEND_SWITCH_LONG
&& opline->opcode != ZEND_SWITCH_STRING
&& opline->opcode != ZEND_MATCH
&& opline->opcode != ZEND_MATCH_ERROR
&& opline->opcode != ZEND_JMP_NULL
&& (opline->opcode != ZEND_FREE
|| opline->extended_value != ZEND_FREE_ON_RETURN);
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ static bool keeps_op1_alive(zend_op *opline) {
|| opline->opcode == ZEND_SWITCH_LONG
|| opline->opcode == ZEND_SWITCH_STRING
|| opline->opcode == ZEND_MATCH
|| opline->opcode == ZEND_MATCH_ERROR
|| opline->opcode == ZEND_FETCH_LIST_R
|| opline->opcode == ZEND_FETCH_LIST_W
|| opline->opcode == ZEND_COPY_TMP) {
Expand Down
21 changes: 21 additions & 0 deletions ext/opcache/tests/gh17106.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
GH-17106: ZEND_MATCH_ERROR misoptimization
--EXTENSIONS--
opcache
--INI--
opcache.enable_cli=1
opcache.optimization_level=-1
--FILE--
<?php

const X = 2;

var_dump(7 ?? match (X) {});
var_dump(null ?? match (X) { 2 => 2 });
var_dump(match (X) { 2 => 2 });

?>
--EXPECT--
int(7)
int(2)
int(2)
12 changes: 6 additions & 6 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ PHP_FUNCTION(socket_get_option)
struct linger linger_val;
struct timeval tv;
#ifdef PHP_WIN32
int timeout = 0;
DWORD timeout = 0;
#endif
socklen_t optlen;
php_socket *php_sock;
Expand Down Expand Up @@ -1757,15 +1757,15 @@ PHP_FUNCTION(socket_get_option)
RETURN_FALSE;
}
#else
optlen = sizeof(int);
optlen = sizeof(timeout);

if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}

tv.tv_sec = timeout ? timeout / 1000 : 0;
tv.tv_usec = timeout ? (timeout * 1000) % 1000000 : 0;
tv.tv_sec = timeout ? (long)(timeout / 1000) : 0;
tv.tv_usec = timeout ? (long)((timeout * 1000) % 1000000) : 0;
#endif

array_init(return_value);
Expand Down Expand Up @@ -1874,7 +1874,7 @@ PHP_FUNCTION(socket_set_option)
php_socket *php_sock;
int ov, optlen, retval;
#ifdef PHP_WIN32
int timeout;
DWORD timeout;
#else
struct timeval tv;
#endif
Expand Down Expand Up @@ -2019,7 +2019,7 @@ PHP_FUNCTION(socket_set_option)
opt_ptr = &tv;
#else
timeout = Z_LVAL_P(sec) * 1000 + Z_LVAL_P(usec) / 1000;
optlen = sizeof(int);
optlen = sizeof(timeout);
opt_ptr = &timeout;
#endif
break;
Expand Down
25 changes: 0 additions & 25 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -3070,18 +3070,6 @@ function get_summary(bool $show_ext_summary): string
$failed_test_summary .= "=====================================================================\n";
}

if (count($PHP_FAILED_TESTS['XFAILED'])) {
$failed_test_summary .= '
=====================================================================
EXPECTED FAILED TEST SUMMARY
---------------------------------------------------------------------
';
foreach ($PHP_FAILED_TESTS['XFAILED'] as $failed_test_data) {
$failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
}
$failed_test_summary .= "=====================================================================\n";
}

if (count($PHP_FAILED_TESTS['BORKED'])) {
$failed_test_summary .= '
=====================================================================
Expand Down Expand Up @@ -3132,19 +3120,6 @@ function get_summary(bool $show_ext_summary): string
$failed_test_summary .= "=====================================================================\n";
}

if (count($PHP_FAILED_TESTS['XLEAKED'])) {
$failed_test_summary .= '
=====================================================================
EXPECTED LEAK TEST SUMMARY
---------------------------------------------------------------------
';
foreach ($PHP_FAILED_TESTS['XLEAKED'] as $failed_test_data) {
$failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
}

$failed_test_summary .= "=====================================================================\n";
}

if ($failed_test_summary && !getenv('NO_PHPTEST_SUMMARY')) {
$summary .= $failed_test_summary;
}
Expand Down
Loading