Fix: lib: field.c: calling _PUT_REF() on unique objects on error
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 8 Oct 2019 13:50:47 +0000 (09:50 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 9 Oct 2019 18:14:29 +0000 (14:14 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I91b22cc4afa492f56cf2a1f460bb29dd61c96c08
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2150
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/trace-ir/field.c

index 7f2225ddef8496d4e64da8ad2231e21a12273e87..e2e77cc7ca6a219dad7820af90d67da9e73c8be6 100644 (file)
@@ -393,7 +393,8 @@ struct bt_field *create_string_field(struct bt_field_class *fc)
                sizeof(char), 1);
        if (!string_field->buf) {
                BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
-               BT_OBJECT_PUT_REF_AND_RESET(string_field);
+               bt_field_destroy((void *) string_field);
+               string_field = NULL;
                goto end;
        }
 
@@ -462,7 +463,8 @@ struct bt_field *create_structure_field(struct bt_field_class *fc)
                        &struct_field->fields)) {
                BT_LIB_LOGE_APPEND_CAUSE(
                        "Cannot create structure member fields: %![fc-]+F", fc);
-               BT_OBJECT_PUT_REF_AND_RESET(struct_field);
+               bt_field_destroy((void *) struct_field);
+               struct_field = NULL;
                goto end;
        }
 
@@ -493,7 +495,8 @@ struct bt_field *create_option_field(struct bt_field_class *fc)
                        "Failed to create option field's content field: "
                        "%![opt-fc-]+F, %![content-fc-]+F",
                        opt_fc, opt_fc->content_fc);
-               BT_OBJECT_PUT_REF_AND_RESET(opt_field);
+               bt_field_destroy((void *) opt_field);
+               opt_field = NULL;
                goto end;
        }
 
@@ -522,7 +525,8 @@ struct bt_field *create_variant_field(struct bt_field_class *fc)
                        &var_field->fields)) {
                BT_LIB_LOGE_APPEND_CAUSE("Cannot create variant member fields: "
                        "%![fc-]+F", fc);
-               BT_OBJECT_PUT_REF_AND_RESET(var_field);
+               bt_field_destroy((void *) var_field);
+               var_field = NULL;
                goto end;
        }
 
@@ -588,7 +592,8 @@ struct bt_field *create_static_array_field(struct bt_field_class *fc)
        if (init_array_field_fields(array_field)) {
                BT_LIB_LOGE_APPEND_CAUSE("Cannot create static array fields: "
                        "%![fc-]+F", fc);
-               BT_OBJECT_PUT_REF_AND_RESET(array_field);
+               bt_field_destroy((void *) array_field);
+               array_field = NULL;
                goto end;
        }
 
@@ -616,7 +621,8 @@ struct bt_field *create_dynamic_array_field(struct bt_field_class *fc)
        if (init_array_field_fields(array_field)) {
                BT_LIB_LOGE_APPEND_CAUSE("Cannot create dynamic array fields: "
                        "%![fc-]+F", fc);
-               BT_OBJECT_PUT_REF_AND_RESET(array_field);
+               bt_field_destroy((void *) array_field);
+               array_field = NULL;
                goto end;
        }
 
This page took 0.026278 seconds and 4 git commands to generate.