Skip to content

Get rid of remaining usages of zval_try_get_string() in ext/dom #14041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions ext/dom/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,8 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);

zend_string *str = zval_try_get_string(newval);
if (UNEXPECTED(!str)) {
return FAILURE;
}
/* Cannot fail because the type is either null or a string. */
zend_string *str = zval_get_string(newval);

if (php_dom_follow_spec_intern(obj)) {
if (!zend_string_equals_literal(str, "1.0") && !zend_string_equals_literal(str, "1.1")) {
Expand Down Expand Up @@ -396,10 +394,8 @@ zend_result dom_document_document_uri_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);

zend_string *str = zval_try_get_string(newval);
if (UNEXPECTED(!str)) {
return FAILURE;
}
/* Cannot fail because the type is either null or a string. */
zend_string *str = zval_get_string(newval);

if (docp->URL != NULL) {
xmlFree(BAD_CAST docp->URL);
Expand Down Expand Up @@ -1780,7 +1776,6 @@ PHP_METHOD(DOMDocument, xinclude)
} else {
RETVAL_FALSE;
}

}
/* }}} */

Expand Down
6 changes: 2 additions & 4 deletions ext/dom/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ zend_result dom_node_node_value_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlNodePtr, nodep, obj);

zend_string *str = zval_try_get_string(newval);
if (UNEXPECTED(!str)) {
return FAILURE;
}
/* Cannot fail because the type is either null or a string. */
zend_string *str = zval_get_string(newval);

/* Access to Element node is implemented as a convenience method */
switch (nodep->type) {
Expand Down