Skip to content

Commit

Permalink
Merge pull request #3203 from techee/cxx_mem_leak
Browse files Browse the repository at this point in the history
cxx: use a trashbox for deleteing tokens allocated for anonymous parameters
  • Loading branch information
techee committed Sep 21, 2022
2 parents 0bc92b0 + fc852aa commit 740377e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ctags/parsers/cxx/cxx_parser_function.c
Expand Up @@ -1889,6 +1889,8 @@ void cxxParserEmitFunctionParameterTags(CXXTypedVariableSet * pInfo)

if(pTypeName)
{
if (pInfo->uAnonymous & (0x1u << i))
PARSER_TRASH_BOX_TAKE_BACK (pInfo->aIdentifiers[i]);
cxxTokenDestroy(pInfo->aIdentifiers[i]);
cxxTokenDestroy(pTypeName);
}
Expand Down Expand Up @@ -2180,6 +2182,7 @@ bool cxxParserTokenChainLooksLikeFunctionParameterList(
pIdentifier->iLineNumber = t->pPrev->iLineNumber;
pIdentifier->oFilePosition = t->pPrev->oFilePosition;
pParamInfo->uAnonymous |= (0x1u << pParamInfo->uCount);
PARSER_TRASH_BOX (pIdentifier, cxxTokenDestroy);
}
pParamInfo->aIdentifiers[pParamInfo->uCount] = pIdentifier;
pParamInfo->uCount++;
Expand Down Expand Up @@ -2233,7 +2236,7 @@ bool cxxParserTokenChainLooksLikeFunctionParameterList(
pParamInfo->uCount++;

PARSER_TRASH_BOX (pFakeStart, cxxTokenDestroy);
/* pFakeId may be destroyed via pParamInfo->aIdentifiers[i]. */
PARSER_TRASH_BOX (pFakeId, cxxTokenDestroy);
}

if(cxxTokenTypeIs(t,CXXTokenTypeClosingParenthesis))
Expand Down

0 comments on commit 740377e

Please sign in to comment.