From 85ddfc814f33943199928447b4627d05b0920b99 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 14 Nov 2015 13:50:56 +0100 Subject: [PATCH] Fixed a couple of small memory leaks --- src/classdef.cpp | 2 +- src/pre.l | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/classdef.cpp b/src/classdef.cpp index fa555acf6cb..88f9a7074f2 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -2603,7 +2603,7 @@ void ClassDef::setTypeConstraints(ArgumentList *al) void ClassDef::setTemplateArguments(ArgumentList *al) { if (al==0) return; - if (!m_impl->tempArgs) delete m_impl->tempArgs; // delete old list if needed + if (m_impl->tempArgs) delete m_impl->tempArgs; // delete old list if needed //printf("setting template args '%s' for '%s'\n",tempArgListToString(al,getLanguage()).data(),name().data()); m_impl->tempArgs=new ArgumentList; ArgumentListIterator ali(*al); diff --git a/src/pre.l b/src/pre.l index 86f9ebbb831..18f3b1d96ec 100644 --- a/src/pre.l +++ b/src/pre.l @@ -1659,6 +1659,7 @@ static void endCondSection() { CondCtx *ctx = g_condStack.pop(); g_skip=ctx->skip; + delete ctx; } //printf("endCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count()); } @@ -1667,7 +1668,7 @@ static void forceEndCondSection() { while (!g_condStack.isEmpty()) { - g_condStack.pop(); + delete g_condStack.pop(); } g_skip=FALSE; } @@ -3010,8 +3011,8 @@ void preprocessFile(const char *fileName,BufStr &input,BufStr &output) g_includeStack.clear(); g_expandedDict->setAutoDelete(FALSE); g_expandedDict->clear(); - g_condStack.clear(); g_condStack.setAutoDelete(TRUE); + g_condStack.clear(); //g_fileDefineDict->clear(); setFileName(fileName); @@ -3161,6 +3162,7 @@ void preprocessFile(const char *fileName,BufStr &input,BufStr &output) if (ctx->sectionId!=" ") sectionInfo.sprintf(" with label %s ",ctx->sectionId.data()); warn(fileName,ctx->lineNr,"Conditional section%sdoes not have " "a corresponding \\endcond command within this file.",sectionInfo.data()); + delete ctx; } // make sure we don't extend a \cond with missing \endcond over multiple files (see bug 624829) forceEndCondSection();