From 92c8b4f90f1b9c12547623f24b756b4167b4d59a Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 7 Apr 2015 18:10:15 -0400 Subject: [PATCH] Fix: ir: incr ref of existing sequence/array field MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-fields.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/formats/ctf/ir/event-fields.c b/formats/ctf/ir/event-fields.c index 6220144a..e05fd324 100644 --- a/formats/ctf/ir/event-fields.c +++ b/formats/ctf/ir/event-fields.c @@ -524,12 +524,14 @@ struct bt_ctf_field *bt_ctf_field_array_get_field(struct bt_ctf_field *field, } new_field = bt_ctf_field_create(field_type); - bt_ctf_field_get(new_field); array->elements->pdata[(size_t)index] = new_field; end: if (field_type) { bt_ctf_field_type_put(field_type); } + if (new_field) { + bt_ctf_field_get(new_field); + } return new_field; } @@ -557,12 +559,14 @@ struct bt_ctf_field *bt_ctf_field_sequence_get_field(struct bt_ctf_field *field, } new_field = bt_ctf_field_create(field_type); - bt_ctf_field_get(new_field); sequence->elements->pdata[(size_t)index] = new_field; end: if (field_type) { bt_ctf_field_type_put(field_type); } + if (new_field) { + bt_ctf_field_get(new_field); + } return new_field; } -- 2.34.1