From b5541a002330bf4dd47f03f2b4dab58bb1392e60 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 17 Oct 2018 17:37:47 +0200 Subject: [PATCH] Fix: Argv may be corrupted after InitGoogleMock found any related flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:5996 Change-Id: I42f3c7eef990e06f89d7c847b0ccc89abe257111 Reviewed-on: https://webrtc-review.googlesource.com/c/106707 Commit-Queue: Artem Titov Reviewed-by: Patrik Höglund Cr-Commit-Position: refs/heads/master@{#25244} --- test/test_main.cc | 2 +- test/test_main_lib.cc | 6 +++--- test/test_main_lib.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_main.cc b/test/test_main.cc index fb9aa2070f..1a311f63c2 100644 --- a/test/test_main.cc +++ b/test/test_main.cc @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) { std::unique_ptr main = webrtc::TestMain::Create(); - int err_code = main->Init(argc, argv); + int err_code = main->Init(&argc, argv); if (err_code != 0) { return err_code; } diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index bcd08576ac..add24af01e 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -79,8 +79,8 @@ namespace { class TestMainImpl : public TestMain { public: - int Init(int argc, char* argv[]) override { - ::testing::InitGoogleMock(&argc, argv); + int Init(int* argc, char* argv[]) override { + ::testing::InitGoogleMock(argc, argv); // Default to LS_INFO, even for release builds to provide better test // logging. @@ -88,7 +88,7 @@ class TestMainImpl : public TestMain { if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO) rtc::LogMessage::LogToDebug(rtc::LS_INFO); - if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false)) { + if (rtc::FlagList::SetFlagsFromCommandLine(argc, argv, false)) { return 1; } if (FLAG_help) { diff --git a/test/test_main_lib.h b/test/test_main_lib.h index 9e859869dd..44dd764ae2 100644 --- a/test/test_main_lib.h +++ b/test/test_main_lib.h @@ -24,7 +24,7 @@ class TestMain { // Initializes test environment. Clients can add their own initialization // steps after call to this method and before running tests. // Returns 0 if initialization was successful and non 0 otherwise. - virtual int Init(int argc, char* argv[]) = 0; + virtual int Init(int* argc, char* argv[]) = 0; // Runs test end return result error code. 0 - no errors. virtual int Run(int argc, char* argv[]) = 0;