summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-09-17 14:24:17 (GMT)
committerBrad King <brad.king@kitware.com>2013-09-17 14:27:08 (GMT)
commitad3d5c59b3c57112e3b96812ee8a66b08dcd864e (patch)
treef864a5ecfc989d2640b559fe3aa0e8f667db8a61 /Source
parent40c76c1dc84867aae6ef1b6138abed5de3eeb28b (diff)
downloadCMake-ad3d5c59b3c57112e3b96812ee8a66b08dcd864e.zip
CMake-ad3d5c59b3c57112e3b96812ee8a66b08dcd864e.tar.gz
CMake-ad3d5c59b3c57112e3b96812ee8a66b08dcd864e.tar.bz2
cmListFileLexer: Fix leak on error before EOF
Teach cmListFileLexerDestroy to call cmListFileLexerSetToken with a NULL token to free the token string buffer. Without this, if an error occurs before the token cleanup happens when EOF is reached, then the token string buffer may leak.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmListFileLexer.c1
-rw-r--r--Source/cmListFileLexer.in.l1
2 files changed, 2 insertions, 0 deletions
diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c
index 2841fe5..f127add 100644
--- a/Source/cmListFileLexer.c
+++ b/Source/cmListFileLexer.c
@@ -2271,6 +2271,7 @@ static void cmListFileLexerInit(cmListFileLexer* lexer)
/*--------------------------------------------------------------------------*/
static void cmListFileLexerDestroy(cmListFileLexer* lexer)
{
+ cmListFileLexerSetToken(lexer, 0, 0);
if(lexer->file || lexer->string_buffer)
{
cmListFileLexer_yylex_destroy(lexer->scanner);
diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l
index 12b53ee..bd3c1eb 100644
--- a/Source/cmListFileLexer.in.l
+++ b/Source/cmListFileLexer.in.l
@@ -292,6 +292,7 @@ static void cmListFileLexerInit(cmListFileLexer* lexer)
/*--------------------------------------------------------------------------*/
static void cmListFileLexerDestroy(cmListFileLexer* lexer)
{
+ cmListFileLexerSetToken(lexer, 0, 0);
if(lexer->file || lexer->string_buffer)
{
cmListFileLexer_yylex_destroy(lexer->scanner);