Skip to content

Commit

Permalink
encoding: opentelemetry: do not memcpy on null ref (CID 508108)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Aug 27, 2024
1 parent 8c27456 commit acff4f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cmt_encode_opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,13 +711,13 @@ static inline Opentelemetry__Proto__Common__V1__AnyValue *cfl_variant_binary_to_
result->bytes_value.len = cfl_sds_len(value->data.as_bytes);
result->bytes_value.data = calloc(result->bytes_value.len, sizeof(char));

if (result->bytes_value.data == NULL) {
if (result->bytes_value.data) {
memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len);
}
else {
otlp_any_value_destroy(result);

result = NULL;
}

memcpy(result->bytes_value.data, value->data.as_bytes, result->bytes_value.len);
}

return result;
Expand Down

0 comments on commit acff4f0

Please sign in to comment.