Skip to content

Commit 7a536fd

Browse files
committed
Review zend_is_true() usage in zend_ast.c
1 parent f9c567e commit 7a536fd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Zend/zend_ast.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,18 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
604604
break;
605605
}
606606
ZVAL_BOOL(result, zend_is_true(&op2));
607+
/* op2 is an object which cannot be converted to bool */
608+
if (UNEXPECTED(EG(exception))) {
609+
ZVAL_UNDEF(result);
610+
return FAILURE;
611+
}
607612
zval_ptr_dtor_nogc(&op2);
608613
} else {
614+
/* op1 is an object which cannot be converted to bool */
615+
if (UNEXPECTED(EG(exception))) {
616+
ZVAL_UNDEF(result);
617+
return FAILURE;
618+
}
609619
ZVAL_FALSE(result);
610620
}
611621
zval_ptr_dtor_nogc(&op1);
@@ -618,12 +628,22 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
618628
if (zend_is_true(&op1)) {
619629
ZVAL_TRUE(result);
620630
} else {
631+
/* op1 is an object which cannot be converted to bool */
632+
if (UNEXPECTED(EG(exception))) {
633+
ZVAL_UNDEF(result);
634+
return FAILURE;
635+
}
621636
if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[1], scope) != SUCCESS)) {
622637
zval_ptr_dtor_nogc(&op1);
623638
ret = FAILURE;
624639
break;
625640
}
626641
ZVAL_BOOL(result, zend_is_true(&op2));
642+
/* op2 is an object which cannot be converted to bool */
643+
if (UNEXPECTED(EG(exception))) {
644+
ZVAL_UNDEF(result);
645+
return FAILURE;
646+
}
627647
zval_ptr_dtor_nogc(&op2);
628648
}
629649
zval_ptr_dtor_nogc(&op1);
@@ -645,6 +665,10 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast
645665
zval_ptr_dtor_nogc(&op1);
646666
}
647667
} else {
668+
/* op1 is an object which cannot be converted to bool */
669+
if (UNEXPECTED(EG(exception))) {
670+
return FAILURE;
671+
}
648672
if (UNEXPECTED(zend_ast_evaluate(result, ast->child[2], scope) != SUCCESS)) {
649673
zval_ptr_dtor_nogc(&op1);
650674
ret = FAILURE;

0 commit comments

Comments
 (0)