summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: */