From 7f85cf19686452d58ff6a73ddcad79a24fa7f5a7 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:33:24 +0200 Subject: [PATCH] Get rid of remaining usages of zval_try_get_string() This isn't necessary because the cases where we use it will always succeed because the properties always have the type string|null. --- ext/dom/document.c | 13 ++++--------- ext/dom/node.c | 6 ++---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/ext/dom/document.c b/ext/dom/document.c index 5e2457483f6d3..f6a778f086ddd 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -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")) { @@ -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); @@ -1780,7 +1776,6 @@ PHP_METHOD(DOMDocument, xinclude) } else { RETVAL_FALSE; } - } /* }}} */ diff --git a/ext/dom/node.c b/ext/dom/node.c index 1f36b222b54b6..86585c085deb0 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -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) {