[libxml2] Fix null pointer dereference in xmlTextReaderReadOuterXml



commit 2c8dc7158a3b7b028454abcb6f162c4da28ed80b
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Mon Feb 25 12:00:50 2019 +0100

    Fix null pointer dereference in xmlTextReaderReadOuterXml
    
    Fix a regression caused by commit 39fbfb4f. If xmlTextReaderReadOuterXml
    is called on a pristine xmlReader, the current node is NULL and must not
    be dereferenced. Move the call to xmlTextReaderExpand to the start of
    the function to make sure that we have a valid node.
    
    Fixes #43.

 xmlreader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/xmlreader.c b/xmlreader.c
index cd1fb5fe..b8e98287 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -1759,11 +1759,11 @@ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
     xmlBufferPtr buff;
     xmlDocPtr doc;
 
-    node = reader->node;
-    doc = node->doc;
     if (xmlTextReaderExpand(reader) == NULL) {
         return NULL;
     }
+    node = reader->node;
+    doc = node->doc;
     /* XXX: Why is the node copied? */
        if (node->type == XML_DTD_NODE) {
                node = (xmlNodePtr) xmlCopyDtd((xmlDtdPtr) node);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]