Avoid string allocation in dom_get_dom1_attribute() for as long as possible

This commit is contained in:
Niels Dossche 2023-07-13 13:31:31 +02:00
parent 66e2aa7255
commit 9880c336be

View file

@ -159,8 +159,7 @@ static xmlNodePtr dom_get_dom1_attribute(xmlNodePtr elem, xmlChar *name) /* {{{
nqname = xmlSplitQName3(name, &len);
if (nqname != NULL) {
xmlNsPtr ns;
xmlChar *prefix = xmlStrndup(name, len);
if (prefix && xmlStrEqual(prefix, (xmlChar *)"xmlns")) {
if (strncmp((const char *) name, "xmlns:", len + 1) == 0) {
ns = elem->nsDef;
while (ns) {
if (xmlStrEqual(ns->prefix, nqname)) {
@ -168,9 +167,9 @@ static xmlNodePtr dom_get_dom1_attribute(xmlNodePtr elem, xmlChar *name) /* {{{
}
ns = ns->next;
}
xmlFree(prefix);
return (xmlNodePtr)ns;
}
xmlChar *prefix = xmlStrndup(name, len);
ns = xmlSearchNs(elem->doc, elem, prefix);
if (prefix != NULL) {
xmlFree(prefix);