Fix: ir: copy struct/seq/array NULL fields
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 8 Apr 2015 00:02:50 +0000 (20:02 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 28 Apr 2015 19:15:35 +0000 (15:15 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-fields.c

index e05fd3244bc53749614f3e7698cb423f121058e7..257ad523cc8ae20918c7d33d1b149d6b23f6042c 100644 (file)
@@ -1932,13 +1932,19 @@ int bt_ctf_field_structure_copy(struct bt_ctf_field *src,
        g_ptr_array_set_size(struct_dst->fields, struct_src->fields->len);
 
        for (i = 0; i < struct_src->fields->len; i++) {
-               struct bt_ctf_field *field_copy = bt_ctf_field_copy(
-                       g_ptr_array_index(struct_src->fields, i));
+               struct bt_ctf_field *field =
+                       g_ptr_array_index(struct_src->fields, i);
+               struct bt_ctf_field *field_copy = NULL;
 
-               if (!field_copy) {
-                       ret = -1;
-                       goto end;
+               if (field) {
+                       field_copy = bt_ctf_field_copy(field);
+
+                       if (!field_copy) {
+                               ret = -1;
+                               goto end;
+                       }
                }
+
                g_ptr_array_index(struct_dst->fields, i) = field_copy;
        }
 end:
@@ -1985,13 +1991,19 @@ int bt_ctf_field_array_copy(struct bt_ctf_field *src,
 
        g_ptr_array_set_size(array_dst->elements, array_src->elements->len);
        for (i = 0; i < array_src->elements->len; i++) {
-               struct bt_ctf_field *field_copy = bt_ctf_field_copy(
-                       g_ptr_array_index(array_src->elements, i));
+               struct bt_ctf_field *field =
+                       g_ptr_array_index(array_src->elements, i);
+               struct bt_ctf_field *field_copy = NULL;
 
-               if (!field_copy) {
-                       ret = -1;
-                       goto end;
+               if (field) {
+                       field_copy = bt_ctf_field_copy(field);
+
+                       if (!field_copy) {
+                               ret = -1;
+                               goto end;
+                       }
                }
+
                g_ptr_array_index(array_dst->elements, i) = field_copy;
        }
 end:
@@ -2037,12 +2049,17 @@ int bt_ctf_field_sequence_copy(struct bt_ctf_field *src,
        assert(sequence_dst->elements->len == sequence_src->elements->len);
 
        for (i = 0; i < sequence_src->elements->len; i++) {
-               struct bt_ctf_field *field_copy = bt_ctf_field_copy(
-                       g_ptr_array_index(sequence_src->elements, i));
+               struct bt_ctf_field *field =
+                       g_ptr_array_index(sequence_src->elements, i);
+               struct bt_ctf_field *field_copy = NULL;
 
-               if (!field_copy) {
-                       ret = -1;
-                       goto end;
+               if (field) {
+                       field_copy = bt_ctf_field_copy(field);
+
+                       if (!field_copy) {
+                               ret = -1;
+                               goto end;
+                       }
                }
 
                g_ptr_array_index(sequence_dst->elements, i) = field_copy;
This page took 0.026143 seconds and 4 git commands to generate.