Skip to content

Commit 51da023

Browse files
committed
Fixed exception handling
1 parent 902b00e commit 51da023

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,14 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
867867

868868
if (Z_TYPE_P(value) != IS_STRING) {
869869
/* Convert to string, just the time to pick the 1st byte */
870-
zend_string *tmp = zval_get_string(value);
870+
zend_string *tmp = zval_try_get_string_func(value);
871+
872+
if (UNEXPECTED(!tmp)) {
873+
if (result) {
874+
ZVAL_UNDEF(result);
875+
}
876+
return;
877+
}
871878

872879
string_len = ZSTR_LEN(tmp);
873880
c = (zend_uchar)ZSTR_VAL(tmp)[0];
@@ -920,12 +927,19 @@ static void ZEND_FASTCALL zend_jit_assign_dim_helper(zval *object_ptr, zval *dim
920927
if (EXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) {
921928
ZVAL_DEREF(value);
922929
Z_OBJ_HT_P(object_ptr)->write_dimension(Z_OBJ_P(object_ptr), dim, value);
923-
if (result && EXPECTED(!EG(exception))) {
924-
ZVAL_COPY(result, value);
930+
if (result) {
931+
if (EXPECTED(!EG(exception))) {
932+
ZVAL_COPY(result, value);
933+
} else {
934+
ZVAL_UNDEF(result);
935+
}
925936
}
926937
} else if (EXPECTED(Z_TYPE_P(object_ptr) == IS_STRING)) {
927938
if (!dim) {
928939
zend_throw_error(NULL, "[] operator not supported for strings");
940+
if (result) {
941+
ZVAL_UNDEF(result);
942+
}
929943
} else {
930944
zend_assign_to_string_offset(object_ptr, dim, value, result);
931945
}

0 commit comments

Comments
 (0)