Low: libcrmcommon: replace_xml_node() segfaults when doc is shared
If the child and update arguments share the same doc, replace_xml_node()
will seg fault during its free_xml(old) call. The exact cause is
difficult to trace; it lies somewhere in the intricacies of libxml2.
If memory serves, the seg fault occurs in a libxml2 call to
DICT_FREE(doc->name), but it's not obvious why that's a problem.
This doesn't cause any known issues with existing code, but it would be
a problem in future commits that involve CIB replaces without making a
copy beforehand (extending cib_zero_copy logic to cib_file and adding
cib_transaction support to cib_file).
The fix is to skip assigning old to the tmp doc (only one line). It
doesn't need to be attached to a doc after it's been replaced. It can
simply be freed, and we can free the doc separately.
The rest of the changes are for readability.
Ref T185
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>