bitmovin / libdash

MPEG-DASH Access Library - Official ISO/IEC MPEG-DASH Reference Implementation
https://bitmovin.com/
589 stars 169 forks source link

Alloc-dealloc mismatch in DOMParser::ProcessNode #32

Open anatols opened 3 years ago

anatols commented 3 years ago

In DOMParser::ProcessNode a string returned from xmlTextReaderReadString is freed by delete operator. It should be done with xmlFree.

I'm not going to contribute a fix via a pull request because you require signing a CLA, which I believe is against the spirit of open source. Here's a patch though, you can apply it yourselves if you want:

--- source/xml/DOMParser.cpp
+++ source/xml/DOMParser.cpp
@@ -113,14 +113,14 @@ Node*   DOMParser::ProcessNode              ()
         return node;
     } else if (type == Text)
     {
-       const char* text = (const char *) xmlTextReaderReadString(this->reader);
+        xmlChar *text = xmlTextReaderReadString(this->reader);

        if(text != NULL)
        {
            Node *node = new Node();
            node->SetType(type);
-           node->SetText(text);
-           delete text;
+           node->SetText((const char *)text);
+           xmlFree(text);
            return node;
        }
     }