Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Fri, 13 May 2022 13:50:07 UTC Commit: fc852aa839acde3c0c854c20dc667d655771704a https://github.com/geany/geany/commit/fc852aa839acde3c0c854c20dc667d65577170...
Log Message: ----------- cxx: use a trashbox for deleteing tokens allocated for anonymous parameters
This is a cherry-picked commit
55ba7264c0722c9519c0fdfacdf2363ad1c59e94
from uctags to address a memory leak reported in
https://github.com/universal-ctags/ctags/issues/3372
Modified Paths: -------------- ctags/parsers/cxx/cxx_parser_function.c
Modified: ctags/parsers/cxx/cxx_parser_function.c 5 lines changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -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); } @@ -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++; @@ -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))
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).