From ad3d5c59b3c57112e3b96812ee8a66b08dcd864e Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 17 Sep 2013 10:24:17 -0400 Subject: [PATCH] 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. --- Source/cmListFileLexer.c | 1 + Source/cmListFileLexer.in.l | 1 + 2 files changed, 2 insertions(+) diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index 2841fe511..f127adde7 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 12b53eef6..bd3c1eb27 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);