Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gRPC]: Fix oob access of string_view in example #1619

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/grpc/tracer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GrpcClientCarrier : public opentelemetry::context::propagation::TextMapCar
opentelemetry::nostd::string_view value) noexcept override
{
std::cout << " Client ::: Adding " << key << " " << value << "\n";
context_->AddMetadata(key.data(), value.data());
context_->AddMetadata(std::string(key), std::string(value));
owent marked this conversation as resolved.
Show resolved Hide resolved
}

ClientContext *context_;
Expand All @@ -52,7 +52,7 @@ class GrpcServerCarrier : public opentelemetry::context::propagation::TextMapCar
virtual opentelemetry::nostd::string_view Get(
opentelemetry::nostd::string_view key) const noexcept override
{
auto it = context_->client_metadata().find(key.data());
auto it = context_->client_metadata().find({key.data(), key.size()});
if (it != context_->client_metadata().end())
{
return it->second.data();
Expand Down