Skip to content

Commit 3d62a3a

Browse files
committed
Fix unlikely memleak
1 parent a069341 commit 3d62a3a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/dom/document.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,7 @@ PHP_METHOD(DOMDocument, createElementNS)
975975
PHP_METHOD(DOM_Document, createElementNS)
976976
{
977977
xmlDocPtr docp;
978-
xmlNodePtr nodep = NULL;
979978
int ret;
980-
int errorcode;
981979
dom_object *intern;
982980
zend_string *name = NULL, *uri;
983981

@@ -988,17 +986,17 @@ PHP_METHOD(DOM_Document, createElementNS)
988986
DOM_GET_OBJ(docp, ZEND_THIS, xmlDocPtr, intern);
989987

990988
xmlChar *localname = NULL, *prefix = NULL;
991-
errorcode = dom_validate_and_extract(uri, name, &localname, &prefix);
989+
int errorcode = dom_validate_and_extract(uri, name, &localname, &prefix);
992990

993991
if (errorcode == 0) {
994992
php_dom_libxml_ns_mapper *ns_mapper = php_dom_get_ns_mapper(intern);
995993
xmlNsPtr ns = php_dom_libxml_ns_mapper_get_ns_raw_prefix_string(ns_mapper, prefix, xmlStrlen(prefix), uri);
996-
nodep = xmlNewDocNode(docp, ns, localname, NULL);
994+
xmlNodePtr nodep = xmlNewDocNode(docp, ns, localname, NULL);
997995
if (UNEXPECTED(nodep == NULL)) {
998996
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
999-
RETURN_THROWS();
997+
} else {
998+
DOM_RET_OBJ(nodep, &ret, intern);
1000999
}
1001-
DOM_RET_OBJ(nodep, &ret, intern);
10021000
} else {
10031001
php_dom_throw_error(errorcode, dom_get_strict_error(intern->document));
10041002
}

0 commit comments

Comments
 (0)