File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -1753,25 +1753,22 @@ PHP_METHOD(SimpleXMLElement, addAttribute)
1753
1753
}
1754
1754
1755
1755
localname = xmlSplitQName2 ((xmlChar * )qname , & prefix );
1756
- if (localname == NULL ) {
1756
+ bool free_localname = localname != NULL ;
1757
+ if (!free_localname ) {
1757
1758
if (nsuri_len > 0 ) {
1758
1759
if (prefix != NULL ) {
1759
1760
xmlFree (prefix );
1760
1761
}
1761
1762
php_error_docref (NULL , E_WARNING , "Attribute requires prefix for namespace" );
1762
1763
return ;
1763
1764
}
1764
- localname = xmlStrdup (( xmlChar * )qname ) ;
1765
+ localname = ( xmlChar * ) qname ;
1765
1766
}
1766
1767
1767
1768
attrp = xmlHasNsProp (node , localname , (xmlChar * )nsuri );
1768
1769
if (attrp != NULL && attrp -> type != XML_ATTRIBUTE_DECL ) {
1769
- xmlFree (localname );
1770
- if (prefix != NULL ) {
1771
- xmlFree (prefix );
1772
- }
1773
1770
php_error_docref (NULL , E_WARNING , "Attribute already exists" );
1774
- return ;
1771
+ goto out ;
1775
1772
}
1776
1773
1777
1774
if (nsuri != NULL ) {
@@ -1783,7 +1780,10 @@ PHP_METHOD(SimpleXMLElement, addAttribute)
1783
1780
1784
1781
attrp = xmlNewNsProp (node , nsptr , localname , (xmlChar * )value );
1785
1782
1786
- xmlFree (localname );
1783
+ out :
1784
+ if (free_localname ) {
1785
+ xmlFree (localname );
1786
+ }
1787
1787
if (prefix != NULL ) {
1788
1788
xmlFree (prefix );
1789
1789
}
You can’t perform that action at this time.
0 commit comments