Fix: ir: incr ref of existing sequence/array field
[babeltrace.git] / formats / ctf / ir / event-fields.c
index 6220144a2b57bc94d216a73bf1de34f2adbb8388..e05fd3244bc53749614f3e7698cb423f121058e7 100644 (file)
@@ -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;
 }
 
This page took 0.02527 seconds and 4 git commands to generate.