From cd2e501794771d4c6e107f835addb6583f822bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 22 Dec 2009 21:56:00 +0100 Subject: [PATCH] Visual Studio: Fixed unittests --- lib/checkmemoryleak.cpp | 16 +++++++++++----- lib/checkmemoryleak.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index f02bbc2d0..aeb65ad62 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -305,9 +305,11 @@ void CheckMemoryLeak::reportErr(const std::list &callstack, Sever for (std::list::const_iterator it = callstack.begin(); it != callstack.end(); ++it) { + const Token * const tok = *it; + ErrorLogger::ErrorMessage::FileLocation loc; - loc.line = (*it)->linenr(); - loc.file = tokenizer->file(*it); + loc.line = tok->linenr(); + loc.file = tokenizer->file(tok); locations.push_back(loc); } @@ -2593,9 +2595,13 @@ private: CheckLocalLeaks *C = dynamic_cast(*it); if (C && C->allocated) { - CheckMemoryLeak *checkMemleak = dynamic_cast(C->owner); - checkMemleak->memleakError(tok, C->varname, false); - foundError = true; + CheckMemoryLeakInFunction *checkMemleak = static_cast(C->owner); + if (checkMemleak) + { + checkMemleak->memleakError(tok, C->varname, false); + foundError = true; + break; + } } } } diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index abe7dec4d..24710fcc2 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -141,7 +141,7 @@ public: * -# finally, check if the simplified token list contain any leaks. */ -class CheckMemoryLeakInFunction : private Check, private CheckMemoryLeak +class CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak { public: /** This constructor is used when registering this class */