Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alloc-dealloc mismatch in DOMParser::ProcessNode #32

Open
anatols opened this issue Jan 28, 2021 · 0 comments
Open

Alloc-dealloc mismatch in DOMParser::ProcessNode #32

anatols opened this issue Jan 28, 2021 · 0 comments

Comments

@anatols
Copy link

anatols commented Jan 28, 2021

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;
        }
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant