@@ -34,6 +34,7 @@ struct ctrace_span *ctr_span_create(struct ctrace *ctx, struct ctrace_scope_span
34
34
35
35
/* allocate a spanc context */
36
36
span = calloc (1 , sizeof (struct ctrace_span ));
37
+
37
38
if (span == NULL ) {
38
39
ctr_errno ();
39
40
return NULL ;
@@ -47,23 +48,27 @@ struct ctrace_span *ctr_span_create(struct ctrace *ctx, struct ctrace_scope_span
47
48
span -> name = cfl_sds_create (name );
48
49
if (span -> name == NULL ) {
49
50
free (span );
51
+
50
52
return NULL ;
51
53
}
52
54
53
55
/* attributes */
54
56
span -> attr = ctr_attributes_create ();
55
57
if (span -> attr == NULL ) {
58
+ cfl_sds_destroy (span -> name );
56
59
free (span );
60
+
57
61
return NULL ;
58
62
}
63
+
59
64
cfl_list_init (& span -> events );
60
65
cfl_list_init (& span -> links );
61
66
62
67
/* dropped attributes count */
63
68
span -> dropped_attr_count = 0 ;
64
69
65
70
/* if a parent context was given, populate the span parent id */
66
- if (parent && parent -> span_id ) {
71
+ if (parent != NULL && parent -> span_id != NULL ) {
67
72
ctr_span_set_parent_span_id_with_cid (span , parent -> span_id );
68
73
}
69
74
@@ -78,6 +83,7 @@ struct ctrace_span *ctr_span_create(struct ctrace *ctx, struct ctrace_scope_span
78
83
79
84
/* always start a span by default, the start can be overriden later if needed */
80
85
ctr_span_start (ctx , span );
86
+
81
87
return span ;
82
88
}
83
89
0 commit comments