Skip to content

Commit 842a996

Browse files
committed
Fix #20875: null pointer in zend_fetch_property_address
1 parent 8170d54 commit 842a996

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

Zend/zend_execute.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3624,14 +3624,20 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
36243624
ZVAL_ERROR(result);
36253625
goto end;
36263626
}
3627-
if (Z_TYPE_P(ptr) == IS_NULL && Z_NEXT_P(ptr) == 0) {
3628-
ZVAL_NULL(result);
3629-
goto end;
3627+
3628+
if (EXPECTED(Z_TYPE_P(ptr) == IS_NULL)) {
3629+
zend_property_info *prop_info = CACHED_PTR_EX(cache_slot + 2);
3630+
3631+
if (prop_info == NULL) {
3632+
ZVAL_NULL(result);
3633+
goto end;
3634+
}
36303635
}
36313636
} else if (UNEXPECTED(Z_ISERROR_P(ptr))) {
36323637
ZVAL_ERROR(result);
36333638
goto end;
36343639
}
3640+
36353641
ZVAL_INDIRECT(result, ptr);
36363642
flags &= ZEND_FETCH_OBJ_FLAGS;
36373643
if (flags) {
@@ -5937,4 +5943,4 @@ ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode
59375943
break;
59385944
}
59395945
return ret;
5940-
}
5946+
}

Zend/zend_operators.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ static zend_never_inline zval* ZEND_FASTCALL _zendi_convert_scalar_to_number_sil
324324

325325
static zend_never_inline zend_result ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */
326326
{
327-
try_again:
328327
switch (Z_TYPE_P(op)) {
329328
case IS_NULL:
330329
case IS_FALSE:
@@ -360,9 +359,6 @@ static zend_never_inline zend_result ZEND_FASTCALL _zendi_try_convert_scalar_to_
360359
case IS_RESOURCE:
361360
case IS_ARRAY:
362361
return FAILURE;
363-
case IS_REFERENCE:
364-
op = Z_REFVAL_P(op);
365-
goto try_again;
366362
EMPTY_SWITCH_DEFAULT_CASE()
367363
}
368364
}

0 commit comments

Comments
 (0)