From 723b842ca1de2f8565717d7099f8ff61b63f6026 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 12 May 2019 14:23:55 +0200 Subject: Fixed memory leak in reentrant lexers --- src/constexp.l | 5 ++++- src/declinfo.l | 8 +++++--- src/sqlcode.l | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/constexp.l b/src/constexp.l index f5862c7..86cf4c7 100644 --- a/src/constexp.l +++ b/src/constexp.l @@ -126,7 +126,10 @@ bool parseconstexp(const char *fileName,int lineNr,const QCString &s) //printf("Result: %ld\n",(long)g_resultValue); printlex(yy_flex_debug, FALSE, __FILE__, fileName); - return (long)yyextra->g_resultValue!=0; + bool result = (long)yyextra->g_resultValue!=0; + + constexpYYlex_destroy(yyscanner); + return result; } extern "C" { diff --git a/src/declinfo.l b/src/declinfo.l index 696d000..e7e9164 100644 --- a/src/declinfo.l +++ b/src/declinfo.l @@ -243,13 +243,16 @@ static struct declinfoYY_state g_declinfo_extra; void parseFuncDecl(const QCString &decl,bool objC,QCString &cl,QCString &t, QCString &n,QCString &a,QCString &ftl,QCString &exc) { + if (decl.isEmpty()) + { + return; + } declinfoYYlex_init_extra(&g_declinfo_extra, &g_yyscanner); struct yyguts_t *yyg = (struct yyguts_t*)g_yyscanner; printlex(yy_flex_debug, TRUE, __FILE__, NULL); yyextra->inputString = decl; //printf("Input=`%s'\n",yyextra->inputString); - if (yyextra->inputString==0) return; yyextra->inputPosition = 0; yyextra->classTempListFound = FALSE; yyextra->funcTempListFound = FALSE; @@ -324,9 +327,8 @@ void parseFuncDecl(const QCString &decl,bool objC,QCString &cl,QCString &t, // t.data(),cl.data(),n.data(),a.data()); printlex(yy_flex_debug, FALSE, __FILE__, NULL); + declinfoYYlex_destroy(g_yyscanner); return; - - } //extern "C" { // some bogus code to keep the compiler happy diff --git a/src/sqlcode.l b/src/sqlcode.l index 59de849..c3dd679 100644 --- a/src/sqlcode.l +++ b/src/sqlcode.l @@ -375,9 +375,10 @@ void parseSqlCode( bool /*collectXRefs*/ ) { + if (s.isEmpty()) return; + sqlcodeYYlex_init_extra(&sqlcode_extra, &yyscanner); struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; - if (s.isEmpty()) return; yyextra->code = &od; yyextra->inputString = s; @@ -432,6 +433,8 @@ void parseSqlCode( delete yyextra->sourceFileDef; yyextra->sourceFileDef=0; } + + sqlcodeYYlex_destroy(yyscanner); return; } -- cgit v0.12