Skip to content

Commit 55933d9

Browse files
leonardo-albertovichedsiper
authored andcommitted
span: fixed leak and coding style errors
Missing result checks with proper handling added Signed-off-by: Leonardo Alminana <[email protected]>
1 parent f236cbc commit 55933d9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ctr_span.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct ctrace_span *ctr_span_create(struct ctrace *ctx, struct ctrace_scope_span
3434

3535
/* allocate a spanc context */
3636
span = calloc(1, sizeof(struct ctrace_span));
37+
3738
if (span == NULL) {
3839
ctr_errno();
3940
return NULL;
@@ -47,23 +48,27 @@ struct ctrace_span *ctr_span_create(struct ctrace *ctx, struct ctrace_scope_span
4748
span->name = cfl_sds_create(name);
4849
if (span->name == NULL) {
4950
free(span);
51+
5052
return NULL;
5153
}
5254

5355
/* attributes */
5456
span->attr = ctr_attributes_create();
5557
if (span->attr == NULL) {
58+
cfl_sds_destroy(span->name);
5659
free(span);
60+
5761
return NULL;
5862
}
63+
5964
cfl_list_init(&span->events);
6065
cfl_list_init(&span->links);
6166

6267
/* dropped attributes count */
6368
span->dropped_attr_count = 0;
6469

6570
/* 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) {
6772
ctr_span_set_parent_span_id_with_cid(span, parent->span_id);
6873
}
6974

@@ -78,6 +83,7 @@ struct ctrace_span *ctr_span_create(struct ctrace *ctx, struct ctrace_scope_span
7883

7984
/* always start a span by default, the start can be overriden later if needed */
8085
ctr_span_start(ctx, span);
86+
8187
return span;
8288
}
8389

0 commit comments

Comments
 (0)