summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-18 20:18:22 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-18 22:33:13 +0100
commitd643f9d5c66cdf8b6c935484e65b8f24b5ef31f0 (patch)
tree1a699edfe6ea00956cd400dbd0152b5e0658de9d /hwpfilter
parentf433d9cf8be6507f0299492794da9ed5d749a6ad (diff)
ofz: Direct-leak
Change-Id: I40024334b394e4de6a1766321556689234da86ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131840 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/grammar.cxx3
-rw-r--r--hwpfilter/source/lexer.cxx7
-rw-r--r--hwpfilter/source/lexer.hxx6
3 files changed, 11 insertions, 5 deletions
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: */