Skip to content
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
11 changes: 4 additions & 7 deletions ext/dom/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,12 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);

/* Cannot fail because the type is either null or a string. */
zend_string *str = zval_get_string(newval);
/* Type is ?string */
zend_string *str = Z_TYPE_P(newval) == IS_NULL ? ZSTR_EMPTY_ALLOC() : Z_STR_P(newval);

if (php_dom_follow_spec_intern(obj)) {
if (!zend_string_equals_literal(str, "1.0") && !zend_string_equals_literal(str, "1.1")) {
zend_value_error("Invalid XML version");
zend_string_release_ex(str, 0);
return FAILURE;
}
}
Expand All @@ -211,7 +210,6 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval)

docp->version = xmlStrdup((const xmlChar *) ZSTR_VAL(str));

zend_string_release_ex(str, 0);
return SUCCESS;
}

Expand Down Expand Up @@ -394,16 +392,15 @@ zend_result dom_document_document_uri_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);

/* Cannot fail because the type is either null or a string. */
zend_string *str = zval_get_string(newval);
/* Type is ?string */
zend_string *str = Z_TYPE_P(newval) == IS_NULL ? ZSTR_EMPTY_ALLOC() : Z_STR_P(newval);

if (docp->URL != NULL) {
xmlFree(BAD_CAST docp->URL);
}

docp->URL = xmlStrdup((const xmlChar *) ZSTR_VAL(str));

zend_string_release_ex(str, 0);
return SUCCESS;
}

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

/* Cannot fail because the type is either null or a string. */
zend_string *str = zval_get_string(newval);
/* Type is ?string */
zend_string *str = Z_TYPE_P(newval) == IS_NULL ? ZSTR_EMPTY_ALLOC() : Z_STR_P(newval);

/* Access to Element node is implemented as a convenience method */
switch (nodep->type) {
Expand All @@ -213,7 +213,6 @@ zend_result dom_node_node_value_write(dom_object *obj, zval *newval)

php_libxml_invalidate_node_list_cache(obj->document);

zend_string_release_ex(str, 0);
return SUCCESS;
}

Expand Down
10 changes: 6 additions & 4 deletions ext/dom/xpath_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ static zend_result php_dom_xpath_callback_ns_update_method_handler(
ZVAL_PTR(&registered_value, fcc);

if (!key) {
zend_string *str = zval_try_get_string(entry);
zend_string *tmp_str;
zend_string *str = zval_try_get_tmp_string(entry, &tmp_str);
if (str && php_dom_xpath_is_callback_name_valid_and_throw(str, name_validation, true)) {
zend_hash_update(&ns->functions, str, &registered_value);
if (register_func) {
register_func(ctxt, namespace, str);
}
zend_string_release_ex(str, false);
zend_tmp_string_release(tmp_str);
} else {
zend_fcc_dtor(fcc);
efree(fcc);
Expand Down Expand Up @@ -445,9 +446,10 @@ static zend_result php_dom_xpath_callback_dispatch(php_dom_xpath_callbacks *xpat
zval_ptr_dtor(&callback_retval);
return FAILURE;
} else {
zend_string *str = zval_get_string(&callback_retval);
zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(&callback_retval, &tmp_str);
valuePush(ctxt, xmlXPathNewString(BAD_CAST ZSTR_VAL(str)));
zend_string_release_ex(str, 0);
zend_tmp_string_release(tmp_str);
}
zval_ptr_dtor(&callback_retval);
}
Expand Down
Loading