Ticket UUID: 73b0bbd85ece37d314b1af0e67c67002769fcbd4
Title: removeAttributeNS: segmentation fault when there are other attributes with no namespace
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2017-06-17 01:09:49
Version Found In: head
User Comments:
anonymous added on 2017-06-16 10:45:23:

When removeAttributeNS() is called, if the node contains other attributes having no explicit namespace, there is a segmentation fault at dom.c/domRemoveAttributeNS, which in line 3243 assumes the existence of a namespace. Here is a patch:

--- generic/dom.c
+++ generic/dom.c
@@ -3238,11 +3238,11 @@
     attr = node->firstAttr;
     while (attr) {
         domSplitQName (attr->nodeName, prefix, &str);
         if (strcmp(localName,str)==0) {
             ns = domGetNamespaceByIndex(node->ownerDocument, attr->namespace);
-            if (strcmp(ns->uri, uri)==0) {
+            if (ns && strcmp(ns->uri, uri)==0) {
                 if (previous) {
                     previous->nextSibling = attr->nextSibling;
                 } else {
                     attr->parentNode->firstAttr = attr->nextSibling;
                 }


rolf added on 2017-06-17 01:09:49:
Yes. Applied your fix. Thanks.