Skip to content

Commit acff4f0

Browse files
committed
encoding: opentelemetry: do not memcpy on null ref (CID 508108)
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 8c27456 commit acff4f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cmt_encode_opentelemetry.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,13 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *cfl_variant_binary_to_
711711
result->bytes_value.len = cfl_sds_len(value->data.as_bytes);
712712
result->bytes_value.data = calloc(result->bytes_value.len, sizeof(char));
713713

714-
if (result->bytes_value.data == NULL) {
714+
if (result->bytes_value.data) {
715+
memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len);
716+
}
717+
else {
715718
otlp_any_value_destroy(result);
716-
717719
result = NULL;
718720
}
719-
720-
memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len);
721721
}
722722

723723
return result;

0 commit comments

Comments
 (0)