Skip to content

Commit 191d050

Browse files
authored
Cleanup dom_html_document_encoding_write() (#13788)
1 parent 93d3ae2 commit 191d050

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

ext/dom/html_document.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,12 +1342,8 @@ zend_result dom_html_document_encoding_write(dom_object *obj, zval *newval)
13421342
{
13431343
DOM_PROP_NODE(xmlDocPtr, docp, obj);
13441344

1345-
/* Typed property, can only be IS_STRING or IS_NULL. */
1346-
ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING || Z_TYPE_P(newval) == IS_NULL);
1347-
1348-
if (Z_TYPE_P(newval) == IS_NULL) {
1349-
goto invalid_encoding;
1350-
}
1345+
/* Typed property, can only be IS_STRING. */
1346+
ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING);
13511347

13521348
zend_string *str = Z_STR_P(newval);
13531349
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)
13561352
xmlFree(BAD_CAST docp->encoding);
13571353
docp->encoding = xmlStrdup((const xmlChar *) encoding_data->name);
13581354
} else {
1359-
goto invalid_encoding;
1355+
zend_value_error("Invalid document encoding");
1356+
return FAILURE;
13601357
}
13611358

13621359
return SUCCESS;
1363-
1364-
invalid_encoding:
1365-
zend_value_error("Invalid document encoding");
1366-
return FAILURE;
13671360
}
13681361

13691362
#endif /* HAVE_LIBXML && HAVE_DOM */

0 commit comments

Comments
 (0)