Correctly reference the internal string for socket mutator arg

pull/17573/head
yang-g 6 years ago
parent db9be19f5d
commit d6dd6f25f4
  1. 2
      src/cpp/common/channel_arguments.cc
  2. 3
      test/cpp/common/channel_arguments_test.cc

@ -106,7 +106,9 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
}
if (!replaced) {
strings_.push_back(grpc::string(mutator_arg.key));
args_.push_back(mutator_arg);
args_.back().key = const_cast<char*>(strings_.back().c_str());
}
}

@ -209,6 +209,9 @@ TEST_F(ChannelArgumentsTest, SetSocketMutator) {
channel_args_.SetSocketMutator(mutator0);
EXPECT_TRUE(HasArg(arg0));
// Exercise the copy constructor because we ran some sanity checks in it.
grpc::ChannelArguments new_args{channel_args_};
channel_args_.SetSocketMutator(mutator1);
EXPECT_TRUE(HasArg(arg1));
// arg0 is replaced by arg1

Loading…
Cancel
Save