From 3f322e1088911a24a2ac1c7728028a83a5a8f470 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Tue, 10 Apr 2018 14:20:00 -0700 Subject: Fix a memory leak --- test/core/util/fuzzer_corpus_test.cc | 2 ++ test/cpp/naming/resolver_component_tests_runner_invoker.cc | 5 +++-- test/cpp/util/grpc_tool_test.cc | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc index 18bc0ad69e..ebf1913137 100644 --- a/test/core/util/fuzzer_corpus_test.cc +++ b/test/core/util/fuzzer_corpus_test.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -91,6 +92,7 @@ class ExampleGenerator perror("Couldn't open the directory"); abort(); } + gpr_free(test_srcdir); } } } diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc index b2a7890549..6d0708e2f2 100644 --- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc +++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc @@ -165,9 +165,9 @@ int main(int argc, char** argv) { GPR_ASSERT(FLAGS_grpc_test_directory_relative_to_test_srcdir != ""); // Use bazel's TEST_SRCDIR environment variable to locate the "test data" // binaries. + char* test_srcdir = gpr_getenv("TEST_SRCDIR"); std::string const bin_dir = - gpr_getenv("TEST_SRCDIR") + - FLAGS_grpc_test_directory_relative_to_test_srcdir + + test_srcdir + FLAGS_grpc_test_directory_relative_to_test_srcdir + std::string("/test/cpp/naming"); // Invoke bazel's executeable links to the .sh and .py scripts (don't use // the .sh and .py suffixes) to make @@ -177,6 +177,7 @@ int main(int argc, char** argv) { bin_dir + "/" + FLAGS_test_bin_name, bin_dir + "/utils/dns_server", bin_dir + "/resolver_test_record_groups.yaml", bin_dir + "/utils/dns_resolver", bin_dir + "/utils/tcp_connect"); + gpr_free(test_srcdir); } else { // Get the current binary's directory relative to repo root to invoke the // correct build config (asan/tsan/dbg, etc.). diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc index 9f7fec5e93..6574d1bb44 100644 --- a/test/cpp/util/grpc_tool_test.cc +++ b/test/cpp/util/grpc_tool_test.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -738,6 +739,8 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) { FLAGS_metadata = ""; FLAGS_protofiles = ""; + + gpr_free(test_srcdir); } } // namespace testing -- cgit v1.2.3