Skip to content

Commit 948b457

Browse files
committed
Adjust JIT helpers
1 parent 995f2cc commit 948b457

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,11 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval
685685
switch (Z_TYPE_P(dim)) {
686686
case IS_STRING:
687687
{
688-
/* allow errors in string offset for BC reasons */
689-
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) {
690-
/* emit Illegal string warning on leading numerical string */
691-
if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) {
688+
bool trailing_data = false;
689+
/* For BC reasons we allow errors so that we can warn on leading numeric string */
690+
if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL,
691+
/* allow errors */ true, NULL, &trailing_data)) {
692+
if (UNEXPECTED(trailing_data)) {
692693
zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim));
693694
}
694695
goto out;
@@ -832,11 +833,11 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type)
832833
switch(Z_TYPE_P(dim)) {
833834
case IS_STRING:
834835
{
835-
/* allow errors in string offset for BC reasons */
836-
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) {
837-
/* emit Illegal string warning on leading numerical string */
838-
if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)
839-
&& type != BP_VAR_UNSET) {
836+
bool trailing_data = false;
837+
/* For BC reasons we allow errors so that we can warn on leading numeric string */
838+
if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL,
839+
/* allow errors */ true, NULL, &trailing_data)) {
840+
if (UNEXPECTED(trailing_data) && type != BP_VAR_UNSET) {
840841
zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim));
841842
}
842843
return offset;

0 commit comments

Comments
 (0)