From 155aa95f82a4432504995f51dfb030789f9781ed Mon Sep 17 00:00:00 2001 From: Mohan Li <67390330+mohanli-ml@users.noreply.github.com> Date: Mon, 20 Dec 2021 11:09:50 -0800 Subject: [PATCH] Fix memory stomp error in the fallback test client (#28380) * Fix memory stomp error in the fallback test client * Fix memory stomp error in the fallback test client --- test/cpp/interop/grpclb_fallback_test.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/cpp/interop/grpclb_fallback_test.cc b/test/cpp/interop/grpclb_fallback_test.cc index dc4c08a743b..938aea72180 100644 --- a/test/cpp/interop/grpclb_fallback_test.cc +++ b/test/cpp/interop/grpclb_fallback_test.cc @@ -150,7 +150,7 @@ int TcpUserTimeoutCompare(grpc_socket_mutator* /*a*/, return 0; } -void TcpUserTimeoutDestroy(grpc_socket_mutator* mutator) { gpr_free(mutator); } +void TcpUserTimeoutDestroy(grpc_socket_mutator* mutator) { delete mutator; } const grpc_socket_mutator_vtable kTcpUserTimeoutMutatorVtable = grpc_socket_mutator_vtable{TcpUserTimeoutMutateFd, TcpUserTimeoutCompare, @@ -158,9 +158,7 @@ const grpc_socket_mutator_vtable kTcpUserTimeoutMutatorVtable = std::unique_ptr CreateFallbackTestStub() { grpc::ChannelArguments channel_args; - grpc_socket_mutator* tcp_user_timeout_mutator = - static_cast( - gpr_malloc(sizeof(tcp_user_timeout_mutator))); + grpc_socket_mutator* tcp_user_timeout_mutator = new grpc_socket_mutator(); grpc_socket_mutator_init(tcp_user_timeout_mutator, &kTcpUserTimeoutMutatorVtable); channel_args.SetSocketMutator(tcp_user_timeout_mutator);