@@ -124,6 +124,11 @@ static int unpack_instrumentation_scope_attributes(mpack_reader_t *reader, size_
124
124
return CTR_DECODE_MSGPACK_VARIANT_DECODE_ERROR ;
125
125
}
126
126
127
+ if (context -> scope_span -> instrumentation_scope -> attr != NULL ) {
128
+ ctr_attributes_destroy (context -> scope_span -> instrumentation_scope -> attr );
129
+ context -> scope_span -> instrumentation_scope -> attr = NULL ;
130
+ }
131
+
127
132
context -> scope_span -> instrumentation_scope -> attr = attributes ;
128
133
}
129
134
@@ -132,6 +137,7 @@ static int unpack_instrumentation_scope_attributes(mpack_reader_t *reader, size_
132
137
133
138
static int unpack_scope_span_instrumentation_scope (mpack_reader_t * reader , size_t index , void * ctx )
134
139
{
140
+ int result ;
135
141
struct ctrace_instrumentation_scope * instrumentation_scope ;
136
142
struct ctr_msgpack_decode_context * context = ctx ;
137
143
struct ctr_mpack_map_entry_callback_t callbacks [] = \
@@ -151,7 +157,12 @@ static int unpack_scope_span_instrumentation_scope(mpack_reader_t *reader, size_
151
157
152
158
ctr_scope_span_set_instrumentation_scope (context -> scope_span , instrumentation_scope );
153
159
154
- return ctr_mpack_unpack_map (reader , callbacks , ctx );
160
+ result = ctr_mpack_unpack_map (reader , callbacks , ctx );
161
+ if (result != CTR_DECODE_MSGPACK_SUCCESS ) {
162
+ ctr_instrumentation_scope_destroy (context -> scope_span -> instrumentation_scope );
163
+ context -> scope_span -> instrumentation_scope = NULL ;
164
+ }
165
+ return result ;
155
166
}
156
167
157
168
/* Event callbacks */
@@ -541,6 +552,7 @@ static int unpack_span_status(mpack_reader_t *reader, size_t index, void *ctx)
541
552
542
553
static int unpack_span (mpack_reader_t * reader , size_t index , void * ctx )
543
554
{
555
+ int result ;
544
556
struct ctr_msgpack_decode_context * context = ctx ;
545
557
struct ctr_mpack_map_entry_callback_t callbacks [] = \
546
558
{
@@ -565,8 +577,14 @@ static int unpack_span(mpack_reader_t *reader, size_t index, void *ctx)
565
577
if (context -> span == NULL ) {
566
578
return CTR_DECODE_MSGPACK_ALLOCATION_ERROR ;
567
579
}
580
+ result = ctr_mpack_unpack_map (reader , callbacks , ctx );
568
581
569
- return ctr_mpack_unpack_map (reader , callbacks , ctx );
582
+ if (result != CTR_DECODE_MSGPACK_SUCCESS ) {
583
+ ctr_span_destroy (context -> span );
584
+ context -> span = NULL ;
585
+ }
586
+
587
+ return result ;
570
588
}
571
589
572
590
/* Scope span callbacks */
@@ -591,6 +609,7 @@ static int unpack_scope_span_schema_url(mpack_reader_t *reader, size_t index, vo
591
609
592
610
static int unpack_scope_span (mpack_reader_t * reader , size_t index , void * ctx )
593
611
{
612
+ int result ;
594
613
struct ctr_msgpack_decode_context * context = ctx ;
595
614
struct ctr_mpack_map_entry_callback_t callbacks [] = \
596
615
{
@@ -606,7 +625,12 @@ static int unpack_scope_span(mpack_reader_t *reader, size_t index, void *ctx)
606
625
return CTR_DECODE_MSGPACK_ALLOCATION_ERROR ;
607
626
}
608
627
609
- return ctr_mpack_unpack_map (reader , callbacks , ctx );
628
+ result = ctr_mpack_unpack_map (reader , callbacks , ctx );
629
+ if (result != CTR_DECODE_MSGPACK_SUCCESS ) {
630
+ ctr_scope_span_destroy (context -> scope_span );
631
+ context -> scope_span = NULL ;
632
+ }
633
+ return result ;
610
634
}
611
635
612
636
/* Resource span callbacks */
0 commit comments