Skip to content

Commit 72c14b1

Browse files
committed
Review zend_is_true() usage in zend_object_handlers.c
1 parent 78b2cf6 commit 72c14b1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Zend/zend_object_handlers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
634634
*guard &= ~IN_ISSET;
635635

636636
if (!zend_is_true(&tmp_result)) {
637+
/* handles case when tmp_result is an object which cannot be converted to bool */
637638
retval = &EG(uninitialized_zval);
638639
OBJ_RELEASE(zobj);
639640
zval_ptr_dtor(&tmp_result);
@@ -850,6 +851,7 @@ ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int ty
850851
return NULL;
851852
}
852853
if (!i_zend_is_true(rv)) {
854+
/* handles case when tmp_result is an object which cannot be converted to bool */
853855
OBJ_RELEASE(object);
854856
zval_ptr_dtor(&tmp_offset);
855857
zval_ptr_dtor(rv);
@@ -908,12 +910,14 @@ ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check
908910
ZVAL_COPY_DEREF(&tmp_offset, offset);
909911
GC_ADDREF(object);
910912
zend_call_method_with_1_params(object, ce, NULL, "offsetexists", &retval, &tmp_offset);
913+
ZEND_ASSERT(Z_TYPE(retval) != IS_OBJECT);
911914
result = i_zend_is_true(&retval);
912915
zval_ptr_dtor(&retval);
913916
if (check_empty && result && EXPECTED(!EG(exception))) {
914917
zend_call_method_with_1_params(object, ce, NULL, "offsetget", &retval, &tmp_offset);
915918
result = i_zend_is_true(&retval);
916919
zval_ptr_dtor(&retval);
920+
/* TODO: need to do something if retval is an object which cannot be converted to bool? */
917921
}
918922
OBJ_RELEASE(object);
919923
zval_ptr_dtor(&tmp_offset);
@@ -1679,6 +1683,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
16791683
found:
16801684
if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY) {
16811685
result = zend_is_true(value);
1686+
/* TODO: need to do something if retval is an object which cannot be converted to bool? */
16821687
} else if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY) {
16831688
ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_ISSET);
16841689
ZVAL_DEREF(value);
@@ -1711,13 +1716,15 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
17111716
zend_std_call_issetter(zobj, name, &rv);
17121717
result = zend_is_true(&rv);
17131718
zval_ptr_dtor(&rv);
1719+
/* TODO: need to do something if retval is an object which cannot be converted to bool? */
17141720
if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY && result) {
17151721
if (EXPECTED(!EG(exception)) && zobj->ce->__get && !((*guard) & IN_GET)) {
17161722
(*guard) |= IN_GET;
17171723
zend_std_call_getter(zobj, name, &rv);
17181724
(*guard) &= ~IN_GET;
17191725
result = i_zend_is_true(&rv);
17201726
zval_ptr_dtor(&rv);
1727+
/* TODO: need to do something if retval is an object which cannot be converted to bool? */
17211728
} else {
17221729
result = 0;
17231730
}

0 commit comments

Comments
 (0)