diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-01-25 14:52:31 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-01-25 14:52:31 (GMT) |
commit | 938b6dfd1cb5173aa6ab19aa848ae266dba0afff (patch) | |
tree | d497bfa08b6e9448afbede9745f2b004be27aa1e | |
parent | dc67dbe5bd5a48756c591ad02b9f68fbd2a57687 (diff) | |
download | Doxygen-938b6dfd1cb5173aa6ab19aa848ae266dba0afff.zip Doxygen-938b6dfd1cb5173aa6ab19aa848ae266dba0afff.tar.gz Doxygen-938b6dfd1cb5173aa6ab19aa848ae266dba0afff.tar.bz2 |
issue #7527: Doxygen 1.8.17: regression of C macro expansion
-rw-r--r-- | src/pre.l | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -2379,6 +2379,8 @@ static int getNextId(const QCString &expr,int p,int *l) return -1; } +#define MAX_EXPANSION_DEPTH 50 + /*! performs recursive macro expansion on the string \a expr * starting at position \a pos. * May read additional characters from the input while re-scanning! @@ -2392,7 +2394,7 @@ static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in //printf("<expandExpression: empty\n"); return TRUE; } - if (state->expansionDict.find(expr)!=0) // check for recursive expansions + if (state->expansionDict.find(expr)!=0 && level>MAX_EXPANSION_DEPTH) // check for too deep recursive expansions { //printf("<expandExpression: already expanded expr='%s'\n",expr.data()); return FALSE; @@ -2405,6 +2407,8 @@ static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in QCString expMacro; bool definedTest=FALSE; int i=pos,l,p,len; + int startPos = pos; + int samePosCount=0; while ((p=getNextId(expr,i,&l))!=-1) // search for an macro name { bool replaced=FALSE; @@ -2492,6 +2496,20 @@ static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in i=p+l+2; //i=p+l; } + // check for too many inplace expansions without making progress + if (i==startPos) + { + samePosCount++; + } + else + { + startPos=i; + samePosCount=0; + } + if (samePosCount>MAX_EXPANSION_DEPTH) + { + break; + } } else // no re-scan marker found, skip the macro name { |