diff options
author | Luis Hector Chavez <lhchavez@google.com> | 2016-07-27 15:45:15 -0700 |
---|---|---|
committer | Luis Hector Chavez <lhchavez@google.com> | 2016-07-27 15:58:20 -0700 |
commit | 8a886c61ad646fa6cb9c4c5662e84b6630e989f5 (patch) | |
tree | 850f7f9e2fdc8997b0265d982a29e4a92b362faf /base | |
parent | 64ff24167a7f57775a3d2135a87f3f5d4b11b763 (diff) | |
download | libchrome-8a886c61ad646fa6cb9c4c5662e84b6630e989f5.tar.gz |
libchrome: Avoid using CommandLine if it's not initialized
This was causing crashloops in brillo's nativeperms since it initialized
logging without a CommandLine.
TEST=brillo_WebservdSanity
TEST=suite:brillo-smoke
Change-Id: I9aec87bf037d0a00ec362d2afe53242145799e0a
Diffstat (limited to 'base')
-rw-r--r-- | base/logging.cc | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/base/logging.cc b/base/logging.cc index ca310f4410..381e9eea0f 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -357,21 +357,23 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) { // Can log only to the system debug log. CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); #endif - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - // Don't bother initializing |g_vlog_info| unless we use one of the - // vlog switches. - if (command_line->HasSwitch(switches::kV) || - command_line->HasSwitch(switches::kVModule)) { - // NOTE: If |g_vlog_info| has already been initialized, it might be in use - // by another thread. Don't delete the old VLogInfo, just create a second - // one. We keep track of both to avoid memory leak warnings. - CHECK(!g_vlog_info_prev); - g_vlog_info_prev = g_vlog_info; - - g_vlog_info = - new VlogInfo(command_line->GetSwitchValueASCII(switches::kV), - command_line->GetSwitchValueASCII(switches::kVModule), - &g_min_log_level); + if (base::CommandLine::InitializedForCurrentProcess()) { + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + // Don't bother initializing |g_vlog_info| unless we use one of the + // vlog switches. + if (command_line->HasSwitch(switches::kV) || + command_line->HasSwitch(switches::kVModule)) { + // NOTE: If |g_vlog_info| has already been initialized, it might be in use + // by another thread. Don't delete the old VLogInfo, just create a second + // one. We keep track of both to avoid memory leak warnings. + CHECK(!g_vlog_info_prev); + g_vlog_info_prev = g_vlog_info; + + g_vlog_info = + new VlogInfo(command_line->GetSwitchValueASCII(switches::kV), + command_line->GetSwitchValueASCII(switches::kVModule), + &g_min_log_level); + } } g_logging_destination = settings.logging_dest; |