Skip to content

Commit

Permalink
Fixed memory leak in nested comment administration
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Feb 3, 2014
1 parent 0dc96d2 commit 2514ba7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/commentcnv.l
Expand Up @@ -646,7 +646,7 @@ void replaceComment(int offset);
else else
{ {
g_nestingCount--; g_nestingCount--;
CommentCtx *ctx = g_commentStack.pop(); delete g_commentStack.pop();
} }
} }
} }
Expand Down Expand Up @@ -988,7 +988,6 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName)
if (g_lang==SrcLangExt_Markdown) if (g_lang==SrcLangExt_Markdown)
{ {
g_nestingCount=0; g_nestingCount=0;
g_commentStack.clear(); /* to be on the save side */
BEGIN(CComment); BEGIN(CComment);
g_commentStack.push(new CommentCtx(g_lineNr)); g_commentStack.push(new CommentCtx(g_lineNr));
} }
Expand All @@ -1007,14 +1006,15 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName)
} }
if (g_nestingCount>0 || (YY_START==CComment && g_lang!=SrcLangExt_Markdown)) if (g_nestingCount>0 || (YY_START==CComment && g_lang!=SrcLangExt_Markdown))
{ {
QString tmp= "(probable line reference: "; QCString tmp= "(probable line reference: ";
bool first = TRUE; bool first = TRUE;
while (!g_commentStack.isEmpty()) while (!g_commentStack.isEmpty())
{ {
CommentCtx *ctx = g_commentStack.pop(); CommentCtx *ctx = g_commentStack.pop();
if (!first) tmp += ", "; if (!first) tmp += ", ";
tmp += QString::number(ctx->lineNr); tmp += QCString().setNum(ctx->lineNr);
first = FALSE; first = FALSE;
delete ctx;
} }
tmp += ")"; tmp += ")";
warn(g_fileName,g_lineNr,"Reached end of file while still inside a (nested) comment. " warn(g_fileName,g_lineNr,"Reached end of file while still inside a (nested) comment. "
Expand Down

0 comments on commit 2514ba7

Please sign in to comment.