mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-10 08:58:16 +03:00
Handle dumps of corrupted documents more gracefully
Check parent pointers for NULL after the non-recursive rewrite of the serialization code. This avoids segfaults with corrupted documents which can apparently be seen with lxml, see issue #187.
This commit is contained in:
parent
847a3a1181
commit
0b3c64d9f2
@ -903,6 +903,12 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The parent should never be NULL here but we want to handle
|
||||||
|
* corrupted documents gracefully.
|
||||||
|
*/
|
||||||
|
if (cur->parent == NULL)
|
||||||
|
return;
|
||||||
cur = cur->parent;
|
cur = cur->parent;
|
||||||
|
|
||||||
if ((cur->type == XML_HTML_DOCUMENT_NODE) ||
|
if ((cur->type == XML_HTML_DOCUMENT_NODE) ||
|
||||||
|
12
xmlsave.c
12
xmlsave.c
@ -1058,6 +1058,12 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The parent should never be NULL here but we want to handle
|
||||||
|
* corrupted documents gracefully.
|
||||||
|
*/
|
||||||
|
if (cur->parent == NULL)
|
||||||
|
return;
|
||||||
cur = cur->parent;
|
cur = cur->parent;
|
||||||
|
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
@ -1686,6 +1692,12 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The parent should never be NULL here but we want to handle
|
||||||
|
* corrupted documents gracefully.
|
||||||
|
*/
|
||||||
|
if (cur->parent == NULL)
|
||||||
|
return;
|
||||||
cur = cur->parent;
|
cur = cur->parent;
|
||||||
|
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user