HomeClusterLabs Projects

Refactor: various: Drop internal calls to freeXpathObject()

Description

Refactor: various: Drop internal calls to freeXpathObject()

This function appears to have been based on a misunderstanding. We DO
need to set non-namespace-declaration nodes to NULL when accessing them.
We DO NOT need to do this to the remaining nodes in the node set before
freeing the node set.

The issue that we're trying to avoid is checking the type member of a
node in the node set after something else (for example,
xmlNodeSetContent()) has freed it. xmlXPathFreeNodeSet() checks the type
of each node in the node set, freeing namespace declaration nodes and
ignoring others. Then it frees the nodeTab object, but it does NOT free
the non-namespace-declaration nodes within it. It's like freeing a GList
or GHashTable without requesting that the elements inside it be freed.

If we were going to run into a use-after-free issue within
xmlXPathFreeNodeSet(), then we would run into it in freeXpathObject().
The use-after-free happens when type-checking the nodes in the node set.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Mon, Mar 10, 11:40 PM
Parents
rP5fe98f4d2506: Fix: libcib: Don't match element based on XPath matching an attribute
Branches
Unknown
Tags
Unknown