Skip to content

Commit a871c71

Browse files
committed
Fix string offset access
1 parent af5b12e commit a871c71

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
@@ -1428,7 +1428,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
14281428
break;
14291429
}
14301430

1431-
offset = zval_get_long_func(dim, true);
1431+
offset = zval_get_long_func(dim, /* lax */ true);
14321432
} else {
14331433
offset = Z_LVAL_P(dim);
14341434
}
@@ -2361,7 +2361,6 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
23612361

23622362
try_string_offset:
23632363
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
2364-
bool is_lax = false;
23652364
switch (Z_TYPE_P(dim)) {
23662365
case IS_STRING:
23672366
{
@@ -2388,8 +2387,6 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
23882387
case IS_FALSE:
23892388
case IS_TRUE:
23902389
if (type != BP_VAR_IS) {
2391-
/* Warning already occurred */
2392-
is_lax = true;
23932390
zend_error(E_WARNING, "String offset cast occurred");
23942391
}
23952392
break;
@@ -2401,7 +2398,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
24012398
break;
24022399
}
24032400

2404-
offset = zval_get_long_func(dim, is_lax);
2401+
offset = zval_get_long_func(dim, /* is_lax */ true);
24052402
} else {
24062403
offset = Z_LVAL_P(dim);
24072404
}

0 commit comments

Comments
 (0)