Skip to content

Commit b9382f3

Browse files
committed
W.I.P. Make ?? consistent with isset()
1 parent 21663e8 commit b9382f3

File tree

1 file changed

+6
-45
lines changed

1 file changed

+6
-45
lines changed

Zend/zend_execute.c

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
14601460
goto try_again;
14611461
default:
14621462
zend_illegal_string_offset(dim);
1463-
break;
1463+
return 0;
14641464
}
14651465

14661466
offset = zval_get_long_func(dim, /* is_strict */ false);
@@ -2405,51 +2405,12 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
24052405
if (!is_list && EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
24062406
zend_long offset;
24072407

2408-
try_string_offset:
2409-
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
2410-
switch (Z_TYPE_P(dim)) {
2411-
case IS_STRING:
2412-
{
2413-
bool trailing_data = false;
2414-
/* For BC reasons we allow errors so that we can warn on leading numeric string */
2415-
if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset,
2416-
NULL, /* allow errors */ true, NULL, &trailing_data)) {
2417-
if (UNEXPECTED(trailing_data)) {
2418-
zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim));
2419-
}
2420-
goto out;
2421-
}
2422-
if (type == BP_VAR_IS) {
2423-
ZVAL_NULL(result);
2424-
return;
2425-
}
2426-
zend_illegal_string_offset(dim);
2427-
break;
2428-
}
2429-
case IS_UNDEF:
2430-
ZVAL_UNDEFINED_OP2();
2431-
ZEND_FALLTHROUGH;
2432-
case IS_DOUBLE:
2433-
case IS_NULL:
2434-
case IS_FALSE:
2435-
case IS_TRUE:
2436-
if (type != BP_VAR_IS) {
2437-
zend_error(E_WARNING, "String offset cast occurred");
2438-
}
2439-
break;
2440-
case IS_REFERENCE:
2441-
dim = Z_REFVAL_P(dim);
2442-
goto try_string_offset;
2443-
default:
2444-
zend_illegal_string_offset(dim);
2445-
break;
2446-
}
2447-
2448-
offset = zval_get_long_func(dim, /* is_strict */ false);
2449-
} else {
2450-
offset = Z_LVAL_P(dim);
2408+
offset = zend_check_string_offset(dim, BP_VAR_IS EXECUTE_DATA_CC);
2409+
/* Illegal offset */
2410+
if (UNEXPECTED(EG(exception) != NULL)) {
2411+
ZVAL_NULL(result);
2412+
return;
24512413
}
2452-
out:
24532414

24542415
if (UNEXPECTED(Z_STRLEN_P(container) < ((offset < 0) ? -(size_t)offset : ((size_t)offset + 1)))) {
24552416
if (type != BP_VAR_IS) {

0 commit comments

Comments
 (0)