Fix: Argv may be corrupted after InitGoogleMock found any related flags

Bug: webrtc:5996
Change-Id: I42f3c7eef990e06f89d7c847b0ccc89abe257111
Reviewed-on: https://webrtc-review.googlesource.com/c/106707
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25244}
This commit is contained in:
Artem Titov
2018-10-17 17:37:47 +02:00
committed by Commit Bot
parent 576a333876
commit b5541a0023
3 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@
int main(int argc, char* argv[]) {
std::unique_ptr<webrtc::TestMain> 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;
}

View File

@ -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) {

View File

@ -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;