Commit ae489acc authored by Philipp Schafft's avatar Philipp Schafft 🦁

Fix: Ensure references are counted correctly in case reportxml_node_copy() fails

parent c4dca907
......@@ -440,15 +440,18 @@ reportxml_node_t * reportxml_node_copy(reportxml_node_t *node)
}
for (i = 0; i < (size_t)count; i++) {
reportxml_node_t *child = reportxml_node_copy(reportxml_node_get_child(node, i));
reportxml_node_t *child = reportxml_node_get_child(node, i);
reportxml_node_t *copy = reportxml_node_copy(child);
if (!child) {
refobject_unref(child);
if (!copy) {
refobject_unref(ret);
return NULL;
}
if (reportxml_node_add_child(ret, child) != 0) {
refobject_unref(child);
if (reportxml_node_add_child(ret, copy) != 0) {
refobject_unref(copy);
refobject_unref(ret);
return NULL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment