Skip to content

Commit bc0a431

Browse files
committed
Fix string offset access
1 parent 97aa86d commit bc0a431

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ Warning: String offset cast occurred in %s on line %d
7070
string(1) "H"
7171
Float casted to string compile
7272

73-
Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d
74-
7573
Warning: Uninitialized string offset 9223372036854775807 in %s on line %d
7674
TypeError
7775
Float string variable
7876

79-
Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d
80-
8177
Warning: Uninitialized string offset 9223372036854775807 in %s on line %d
8278
TypeError
8379
Attempt to assign

Zend/zend_execute.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
14381438
break;
14391439
}
14401440

1441-
offset = zval_get_long_func(dim, true);
1441+
offset = zval_get_long_func(dim, /* lax */ true);
14421442
} else {
14431443
offset = Z_LVAL_P(dim);
14441444
}
@@ -2374,7 +2374,6 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
23742374

23752375
try_string_offset:
23762376
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
2377-
bool is_lax = false;
23782377
switch (Z_TYPE_P(dim)) {
23792378
case IS_STRING:
23802379
{
@@ -2401,8 +2400,6 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
24012400
case IS_FALSE:
24022401
case IS_TRUE:
24032402
if (type != BP_VAR_IS) {
2404-
/* Warning already occurred */
2405-
is_lax = true;
24062403
zend_error(E_WARNING, "String offset cast occurred");
24072404
}
24082405
break;
@@ -2414,7 +2411,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
24142411
break;
24152412
}
24162413

2417-
offset = zval_get_long_func(dim, is_lax);
2414+
offset = zval_get_long_func(dim, /* is_lax */ true);
24182415
} else {
24192416
offset = Z_LVAL_P(dim);
24202417
}

0 commit comments

Comments
 (0)