[php-src] master: Cleanup dom_html_document_encoding_write() (#13788)
| From: | Niels Dossche via GitHub | Date: | Sat, 23 Mar 2024 21:18:02 +0000 |
| Subject: | [php-src] master: Cleanup dom_html_document_encoding_write() (#13788) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127838@lists.php.net to get a copy of this message | ||
Author: Niels Dossche (nielsdos)
Committer: GitHub (web-flow)
Pusher: nielsdos
Date: 2024-03-23T22:17:58+01:00
Commit: https://github.com/php/php-src/commit/191d0501a5181d311d4529fefbf838af64a64a73
Raw diff: https://github.com/php/php-src/commit/191d0501a5181d311d4529fefbf838af64a64a73.diff
Cleanup dom_html_document_encoding_write() (#13788)
Changed paths:
M ext/dom/html_document.c
Diff:
diff --git a/ext/dom/html_document.c b/ext/dom/html_document.c
index 2735d8fc1189..fe0a447fbb29 100644
--- a/ext/dom/html_document.c
+++ b/ext/dom/html_document.c
@@ -1342,12 +1342,8 @@ zend_result dom_html_document_encoding_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);
- /* Typed property, can only be IS_STRING or IS_NULL. */
- ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING || Z_TYPE_P(newval) == IS_NULL);
-
- if (Z_TYPE_P(newval) == IS_NULL) {
- goto invalid_encoding;
- }
+ /* Typed property, can only be IS_STRING. */
+ ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING);
zend_string *str = Z_STR_P(newval);
const lxb_encoding_data_t *encoding_data = lxb_encoding_data_by_name((const lxb_char_t *)
ZSTR_VAL(str), ZSTR_LEN(str));
@@ -1356,14 +1352,11 @@ zend_result dom_html_document_encoding_write(dom_object *obj, zval *newval)
xmlFree(BAD_CAST docp->encoding);
docp->encoding = xmlStrdup((const xmlChar *) encoding_data->name);
} else {
- goto invalid_encoding;
+ zend_value_error("Invalid document encoding");
+ return FAILURE;
}
return SUCCESS;
-
-invalid_encoding:
- zend_value_error("Invalid document encoding");
- return FAILURE;
}
#endif /* HAVE_LIBXML && HAVE_DOM */