summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-03-25 19:19:07 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-03-25 19:19:07 (GMT)
commitd03499a2001202c9358a7630d74ff61d6bfea9ba (patch)
tree9a55c4306871ea1f77f125a86ae34ad6633634cf
parent72bce7443241675a63ac53739bafa1d00cdbe372 (diff)
downloadDoxygen-d03499a2001202c9358a7630d74ff61d6bfea9ba.zip
Doxygen-d03499a2001202c9358a7630d74ff61d6bfea9ba.tar.gz
Doxygen-d03499a2001202c9358a7630d74ff61d6bfea9ba.tar.bz2
Regression: fix array out of bound issue.
-rw-r--r--src/pyscanner.l12
-rw-r--r--src/scanner.l8
2 files changed, 14 insertions, 6 deletions
diff --git a/src/pyscanner.l b/src/pyscanner.l
index 90f3687..23bdb0b 100644
--- a/src/pyscanner.l
+++ b/src/pyscanner.l
@@ -66,7 +66,7 @@ struct pyscannerYY_state
pyscannerYY_state() : defVal(std::ios_base::ate) {}
CommentScanner commentScanner;
OutlineParserInterface *thisParser = 0;
- QCString inputString;
+ const char * inputString = 0;
yy_size_t inputPosition = 0;
Protection protection = Public;
std::shared_ptr<Entry> current_root;
@@ -107,6 +107,7 @@ struct pyscannerYY_state
QCString argType;
bool funcParamsEnd = FALSE;
std::vector<QCString> decorators;
+ QCString programStr;
};
//-----------------------------------------------------------------------------
@@ -1438,8 +1439,7 @@ static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
yy_size_t c=0;
- if (yyextra->inputString.isEmpty()) return 0;
- const char *p = yyextra->inputString.data() + yyextra->inputPosition;
+ const char *p = yyextra->inputString + yyextra->inputPosition;
while ( c < max_size && *p ) { *buf++ = *p++; c++; }
yyextra->inputPosition+=c;
return c;
@@ -1754,7 +1754,8 @@ static void parseCompounds(yyscan_t yyscanner,std::shared_ptr<Entry> rt)
//fprintf(stderr,"parseCompounds: -- %s (line %d) ---------\n%s\n---------------\n",
// ce->name.data(), ce->bodyLine, ce->program.data());
// init scanner state
- yyextra->inputString = ce->program.str();
+ yyextra->programStr = ce->program.str();
+ yyextra->inputString = yyextra->programStr;
yyextra->inputPosition = 0;
pyscannerYYrestart( 0, yyscanner );
if (ce->section&Entry::COMPOUND_MASK)
@@ -1779,6 +1780,8 @@ static void parseCompounds(yyscan_t yyscanner,std::shared_ptr<Entry> rt)
pyscannerYYlex(yyscanner) ;
yyextra->lexInit=TRUE;
+
+ yyextra->programStr.resize(0);
ce->program.str(std::string());
yyextra->commentScanner.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
@@ -1850,6 +1853,7 @@ static void parseMain(yyscan_t yyscanner, const char *fileName,const char *fileB
yyextra->commentScanner.leaveFile(yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->programStr.resize(0);
yyextra->current_root->program.str(std::string());
parseCompounds(yyscanner, yyextra->current_root);
diff --git a/src/scanner.l b/src/scanner.l
index b529d48..5d62cb3 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -63,7 +63,7 @@ struct scannerYY_state
scannerYY_state() : docBlock(std::ios_base::ate) {}
OutlineParserInterface *thisParser;
CommentScanner commentScanner;
- QCString inputString;
+ const char * inputString = 0;
int inputPosition = 0;
int lastContext = 0;
int lastCContext = 0;
@@ -190,6 +190,7 @@ struct scannerYY_state
uint fencedSize = 0;
bool nestedComment = false;
std::vector< std::pair<Entry*,std::shared_ptr<Entry> > > outerScopeEntries;
+ QCString programStr;
ClangTUParser * clangParser = 0;
};
@@ -7210,7 +7211,8 @@ static void parseCompounds(yyscan_t yyscanner,const std::shared_ptr<Entry> &rt)
yyextra->padCount=0;
//depthIf = 0;
yyextra->column=0;
- yyextra->inputString = ce->program.str();
+ yyextra->programStr = ce->program.str();
+ yyextra->inputString = yyextra->programStr;
yyextra->inputPosition = 0;
if (ce->section==Entry::ENUM_SEC || (ce->spec&Entry::Enum))
BEGIN( FindFields ) ;
@@ -7294,6 +7296,7 @@ static void parseCompounds(yyscan_t yyscanner,const std::shared_ptr<Entry> &rt)
yyextra->commentScanner.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name);
+ yyextra->programStr.resize(0);
ce->program.str(std::string());
@@ -7371,6 +7374,7 @@ static void parseMain(yyscan_t yyscanner,
//forceEndGroup();
yyextra->commentScanner.leaveFile(yyextra->yyFileName,yyextra->yyLineNr);
+ yyextra->programStr.resize(0);
rt->program.str(std::string());
parseCompounds(yyscanner,rt);