Skip to content

Commit 9880c33

Browse files
committed
Avoid string allocation in dom_get_dom1_attribute() for as long as possible
1 parent 66e2aa7 commit 9880c33

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ext/dom/element.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,17 @@ static xmlNodePtr dom_get_dom1_attribute(xmlNodePtr elem, xmlChar *name) /* {{{
159159
nqname = xmlSplitQName3(name, &len);
160160
if (nqname != NULL) {
161161
xmlNsPtr ns;
162-
xmlChar *prefix = xmlStrndup(name, len);
163-
if (prefix && xmlStrEqual(prefix, (xmlChar *)"xmlns")) {
162+
if (strncmp((const char *) name, "xmlns:", len + 1) == 0) {
164163
ns = elem->nsDef;
165164
while (ns) {
166165
if (xmlStrEqual(ns->prefix, nqname)) {
167166
break;
168167
}
169168
ns = ns->next;
170169
}
171-
xmlFree(prefix);
172170
return (xmlNodePtr)ns;
173171
}
172+
xmlChar *prefix = xmlStrndup(name, len);
174173
ns = xmlSearchNs(elem->doc, elem, prefix);
175174
if (prefix != NULL) {
176175
xmlFree(prefix);

0 commit comments

Comments
 (0)