1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

fuzz: Fix namespaces after xmlDOMWrapRemoveNode

This commit is contained in:
Nick Wellnhofer
2024-03-22 14:46:36 +01:00
parent 05c147c3ef
commit d8741b8196

View File

@@ -806,6 +806,11 @@ checkCopy(xmlNodePtr copy) {
return copy; return copy;
} }
/*
* Fix namespaces, for example after unlinking a node. This makes
* sure that the node only references namespaces declared in ancestor
* nodes.
*/
static int static int
fixNs(xmlNodePtr node) { fixNs(xmlNodePtr node) {
if (node == NULL) if (node == NULL)
@@ -3373,8 +3378,11 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
doc != NULL && doc != NULL &&
node->doc == doc && node->doc == doc &&
res < 0); res < 0);
if (node && node->parent != oldParent) if (node != NULL && node->parent != oldParent) {
if (fixNs(node) < 0)
oomReport = 1;
dropNode(oldParent); dropNode(oldParent);
}
endOp(); endOp();
break; break;
} }