From 565b80cc4a88ab420cf5e2138300856888ad9968 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 27 Nov 2011 12:18:24 +0000 Subject: [PATCH] Don't call overridden virtual methods from the base destructor. It causes the program to terminate with "pure virtual method called" error, as the derived class members are no longer accessible. --- common/trace_file.cpp | 4 +++- common/trace_file_snappy.cpp | 1 + common/trace_file_zlib.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/trace_file.cpp b/common/trace_file.cpp index 2210602..3657fd2 100644 --- a/common/trace_file.cpp +++ b/common/trace_file.cpp @@ -28,6 +28,7 @@ #include + using namespace trace; @@ -43,7 +44,8 @@ File::File(const std::string &filename, File::~File() { - close(); + // We can't invoke any overriden virtual method here anymore + assert(!m_isOpened); } diff --git a/common/trace_file_snappy.cpp b/common/trace_file_snappy.cpp index 4d4ecea..5901bfb 100644 --- a/common/trace_file_snappy.cpp +++ b/common/trace_file_snappy.cpp @@ -141,6 +141,7 @@ SnappyFile::SnappyFile(const std::string &filename, SnappyFile::~SnappyFile() { + close(); delete [] m_compressedCache; delete [] m_cache; } diff --git a/common/trace_file_zlib.cpp b/common/trace_file_zlib.cpp index 92cead9..b299b5a 100644 --- a/common/trace_file_zlib.cpp +++ b/common/trace_file_zlib.cpp @@ -73,6 +73,7 @@ ZLibFile::ZLibFile(const std::string &filename, ZLibFile::~ZLibFile() { + close(); } bool ZLibFile::rawOpen(const std::string &filename, File::Mode mode) -- 2.43.0