Skip to content

Commit be17e9e

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix handling of references in zval_try_get_long()
2 parents 307ff3b + 2b38384 commit be17e9e

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

Zend/zend_operators.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ static zend_always_inline zend_result zendi_try_convert_scalar_to_number(zval *o
378378
static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *op, bool *failed) /* {{{ */
379379
{
380380
*failed = 0;
381+
try_again:
381382
switch (Z_TYPE_P(op)) {
382383
case IS_NULL:
383384
case IS_FALSE:
@@ -448,6 +449,14 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *
448449
case IS_ARRAY:
449450
*failed = 1;
450451
return 0;
452+
case IS_REFERENCE:
453+
op = Z_REFVAL_P(op);
454+
if (Z_TYPE_P(op) == IS_LONG) {
455+
return Z_LVAL_P(op);
456+
} else {
457+
goto try_again;
458+
}
459+
break;
451460
EMPTY_SWITCH_DEFAULT_CASE()
452461
}
453462
}

ext/intl/dateformat/dateformat_parse.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,10 @@ PHP_METHOD(IntlDateFormatter, parseToCalendar)
185185
DATE_FORMAT_METHOD_FETCH_OBJECT;
186186

187187
if (z_parse_pos) {
188-
zval *z_parse_pos_tmp = z_parse_pos;
189-
ZVAL_DEREF(z_parse_pos_tmp);
190-
bool failed = false;
191-
zend_long long_parse_pos = zval_try_get_long(z_parse_pos_tmp, &failed);
188+
bool failed;
189+
zend_long long_parse_pos = zval_try_get_long(z_parse_pos, &failed);
192190
if (failed) {
193-
zend_argument_type_error(2, "must be of type int, %s given", zend_zval_value_name(z_parse_pos_tmp));
191+
zend_argument_type_error(2, "must be of type int, %s given", zend_zval_value_name(z_parse_pos));
194192
RETURN_THROWS();
195193
}
196194
if (ZEND_LONG_INT_OVFL(long_parse_pos)) {

ext/mbstring/mbstring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3924,7 +3924,7 @@ static uint32_t *make_conversion_map(HashTable *target_hash, size_t *conversion_
39243924
uint32_t *mapelm = convmap;
39253925

39263926
ZEND_HASH_FOREACH_VAL(target_hash, hash_entry) {
3927-
bool failed = true;
3927+
bool failed;
39283928
zend_long tmp = zval_try_get_long(hash_entry, &failed);
39293929
if (failed) {
39303930
efree(convmap);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
mb_encode_numericentity() reference handling
3+
--EXTENSIONS--
4+
mbstring
5+
--FILE--
6+
<?php
7+
$n = 0;
8+
$convmap = [&$n, 0x1FFFFF, 0, 0x10FFFF];
9+
var_dump(mb_encode_numericentity("", $convmap, "utf8"));
10+
?>
11+
--EXPECT--
12+
string(0) ""

ext/pcntl/pcntl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,7 @@ static bool php_pcntl_set_user_signal_infos(
881881

882882
zval *user_signal_no;
883883
ZEND_HASH_FOREACH_VAL(user_signals, user_signal_no) {
884-
bool failed = true;
885-
ZVAL_DEREF(user_signal_no);
884+
bool failed;
886885
zend_long tmp = zval_try_get_long(user_signal_no, &failed);
887886

888887
if (failed) {

0 commit comments

Comments
 (0)