Skip to content

Commit 154229b

Browse files
committed
Fix JIT str offset handling
1 parent c54fc7a commit 154229b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,14 +1274,17 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva
12741274
switch (Z_TYPE_P(dim)) {
12751275
/* case IS_LONG: */
12761276
case IS_STRING:
1277-
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) {
1278-
break;
1277+
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, false)) {
1278+
goto out;
12791279
}
12801280
ZVAL_NULL(result);
12811281
return;
1282+
case IS_DOUBLE:
1283+
offset = zend_dval_to_lval_silent(Z_DVAL_P(dim));
1284+
goto out;
12821285
case IS_UNDEF:
12831286
zend_jit_undefined_op_helper(EG(current_execute_data)->opline->op2.var);
1284-
case IS_DOUBLE:
1287+
ZEND_FALLTHROUGH;
12851288
case IS_NULL:
12861289
case IS_FALSE:
12871290
case IS_TRUE:
@@ -1302,6 +1305,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva
13021305
offset = Z_LVAL_P(dim);
13031306
}
13041307

1308+
out:
13051309
if ((zend_ulong)offset >= (zend_ulong)ZSTR_LEN(str)) {
13061310
if (offset < 0) {
13071311
/* Handle negative offset */

0 commit comments

Comments
 (0)