Skip to content

Commit 51d93c1

Browse files
committed
Remove failure paths for infallible code in simplexml
For IS_STRING, sxe_object_cast_ex() will call cast_object() which cannot fail for IS_STRING.
1 parent 9979f47 commit 51d93c1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/simplexml/simplexml.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,9 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
467467
case IS_OBJECT:
468468
if (Z_OBJCE_P(value) == ce_SimpleXMLElement) {
469469
zval zval_copy;
470-
if (sxe_object_cast_ex(Z_OBJ_P(value), &zval_copy, IS_STRING) == FAILURE) {
471-
zend_throw_error(NULL, "Unable to cast node to string");
472-
return &EG(error_zval);
473-
}
470+
zend_result rv = sxe_object_cast_ex(Z_OBJ_P(value), &zval_copy, IS_STRING);
471+
ZEND_IGNORE_VALUE(rv);
472+
ZEND_ASSERT(rv == SUCCESS);
474473

475474
value_str = Z_STR(zval_copy);
476475
break;
@@ -1892,10 +1891,9 @@ PHP_METHOD(SimpleXMLElement, __toString)
18921891
RETURN_THROWS();
18931892
}
18941893

1895-
if (sxe_object_cast_ex(Z_OBJ_P(ZEND_THIS), return_value, IS_STRING) != SUCCESS) {
1896-
zval_ptr_dtor(return_value);
1897-
RETURN_EMPTY_STRING();
1898-
}
1894+
zend_result rv = sxe_object_cast_ex(Z_OBJ_P(ZEND_THIS), return_value, IS_STRING);
1895+
ZEND_IGNORE_VALUE(rv);
1896+
ZEND_ASSERT(rv == SUCCESS);
18991897
}
19001898
/* }}} */
19011899

0 commit comments

Comments
 (0)