From: Philippe Proulx Date: Tue, 7 Apr 2015 22:10:15 +0000 (-0400) Subject: Fix: ir: incr ref of existing sequence/array field X-Git-Tag: v2.0.0-pre1~1261 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=92c8b4f90f1b9c12547623f24b756b4167b4d59a Fix: ir: incr ref of existing sequence/array field Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- 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; }