From 916041f1ea33f5cb9de869d28dcdfaa390095c32 Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Mon, 5 Aug 2013 16:17:42 +0200 Subject: Fix logging memory leak. Use a UniquePtr to ensure the LogMessage::data_ member is deleted. Change-Id: Ifbf5e38307c72908579a7adbe1660f99da0e558e --- runtime/base/logging.cc | 2 -- runtime/base/logging.h | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'runtime/base') diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc index 83ecca8..7d54baf 100644 --- a/runtime/base/logging.cc +++ b/runtime/base/logging.cc @@ -156,8 +156,6 @@ LogMessage::~LogMessage() { if (data_->severity == FATAL) { Runtime::Abort(); } - - delete data_; } HexDump::HexDump(const void* address, size_t byte_count, bool show_actual_addresses) diff --git a/runtime/base/logging.h b/runtime/base/logging.h index d641ae4..eafa050 100644 --- a/runtime/base/logging.h +++ b/runtime/base/logging.h @@ -24,6 +24,7 @@ #include #include "base/macros.h" #include "log_severity.h" +#include "UniquePtr.h" #define CHECK(x) \ if (UNLIKELY(!(x))) \ @@ -194,7 +195,7 @@ class LogMessage { private: static void LogLine(const LogMessageData& data, const char*); - LogMessageData* const data_; + const UniquePtr data_; friend void HandleUnexpectedSignal(int signal_number, siginfo_t* info, void* raw_context); friend class Mutex; -- cgit v1.1