hwpfilter/source/grammar.cxx | 3 ++- hwpfilter/source/lexer.cxx | 7 +++++++ hwpfilter/source/lexer.hxx | 6 ++---- 3 files changed, 11 insertions(+), 5 deletions(-)
New commits: commit d643f9d5c66cdf8b6c935484e65b8f24b5ef31f0 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Mar 18 20:18:22 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Mar 18 22:33:13 2022 +0100 ofz: Direct-leak Change-Id: I40024334b394e4de6a1766321556689234da86ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131840 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx index d2c91860aeb6..fdcdbb139d75 100644 --- a/hwpfilter/source/grammar.cxx +++ b/hwpfilter/source/grammar.cxx @@ -1175,12 +1175,13 @@ yyerrhandle: return 1; } - Node *mainParse(const char *_code) { initFlex( _code ); top = nullptr; yyparse(); + deinitFlex(); + if( top ) return top; else diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx index 5d0cef7e2f9d..191f0bce7419 100644 --- a/hwpfilter/source/lexer.cxx +++ b/hwpfilter/source/lexer.cxx @@ -2107,6 +2107,13 @@ void initFlex(const char *_code ) yy_switch_to_buffer( yy_scan_string(_code) ); } +void deinitFlex() +{ + // flex faq-memory-leak + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_init = 1; +} + int yywrap() { yy_delete_buffer( YY_CURRENT_BUFFER ); diff --git a/hwpfilter/source/lexer.hxx b/hwpfilter/source/lexer.hxx index 0f0c1fe1525e..41835f13b51a 100644 --- a/hwpfilter/source/lexer.hxx +++ b/hwpfilter/source/lexer.hxx @@ -17,13 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_HWPFILTER_SOURCE_LEXER_HXX -#define INCLUDED_HWPFILTER_SOURCE_LEXER_HXX +#pragma once void initFlex(char const* s); +void deinitFlex(); int yylex(); -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */