diff --git a/src/ctf-writer/object.h b/src/ctf-writer/object.h
index 70032c2..9e4552a 100644
--- a/src/ctf-writer/object.h
+++ b/src/ctf-writer/object.h
@@ -138,11 +138,13 @@ void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object
 		child->parent = parent;
 		bt_ctf_object_get_no_null_check(parent);
 	} else {
-		if (child->parent) {
-			bt_ctf_object_put_no_null_check(child->parent);
-		}
+		if (child) {
+			if (child->parent) {
+				bt_ctf_object_put_no_null_check(child->parent);
+			}
 
-		child->parent = NULL;
+			child->parent = NULL;
+		}
 	}
 }
 
