From dd8dcdf880d81a599f478bb868a8e8a85d28e7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 17 Jun 2017 10:39:06 +0200 Subject: [PATCH] LogManager: Check if listener is valid before using it --- Source/Core/Common/Logging/LogManager.cpp | 3 ++- Source/Core/Common/Logging/LogManager.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 484151023d03..2aef9318e705 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -164,7 +164,8 @@ void LogManager::LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE LogTypes::LOG_LEVEL_TO_CHAR[(int)level], log->GetShortName().c_str(), temp); for (auto listener_id : *log) - m_listeners[listener_id]->Log(level, msg.c_str()); + if (m_listeners[listener_id]) + m_listeners[listener_id]->Log(level, msg.c_str()); } void LogManager::Init() diff --git a/Source/Core/Common/Logging/LogManager.h b/Source/Core/Common/Logging/LogManager.h index 0ec3c1f7de0b..6562a1705841 100644 --- a/Source/Core/Common/Logging/LogManager.h +++ b/Source/Core/Common/Logging/LogManager.h @@ -86,7 +86,7 @@ class LogManager : NonCopyable private: LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; static LogManager* m_logManager; // Singleton. Ugh. - std::array m_listeners; + std::array m_listeners{}; size_t m_path_cutoff_point = 0; LogManager();