From 5ed184457e505c1cf104918ebec0fc2ce528d89d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 10 Mar 2017 14:11:29 -0500 Subject: [PATCH] Fix: release the reference held by a child to its former parent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The bt_object class' bt_object_set_parent() increments the reference count of the parent since the child now holds a reference to it. This assumes that a child is externally visible when this call is made (as is always the case currently). The parent of a child can be changed in the future. In this case, we want to ensure the reference it held to its former parent is released. Signed-off-by: Jérémie Galarneau --- include/babeltrace/object-internal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/babeltrace/object-internal.h b/include/babeltrace/object-internal.h index 4bf4def6..5c3ca6d9 100644 --- a/include/babeltrace/object-internal.h +++ b/include/babeltrace/object-internal.h @@ -96,6 +96,7 @@ void bt_object_set_parent(void *child_ptr, void *parent) * to the parent will be released once the object's reference count * falls to zero. */ + BT_PUT(child->parent); child->parent = bt_get(parent); } -- 2.34.1