Fix memory leak caused by pattern compilation failure

This commit is contained in:
mAsk° 2023-05-10 05:42:03 +00:00
parent c543387ce0
commit e08e4a5fee
2 changed files with 10 additions and 5 deletions

View file

@ -34,6 +34,8 @@ void yyerror(const char msg[]);
%type <ccl_val> TOK_CCL ccl full_ccl %type <ccl_val> TOK_CCL ccl full_ccl
%type <mach_val> re singleton series string %type <mach_val> re singleton series string
%destructor { delete $$; } <mach_val>
%% %%
flexrule : re flexrule : re
{ $1->AddAccept(1); zeek::detail::nfa = $1; } { $1->AddAccept(1); zeek::detail::nfa = $1; }
@ -50,18 +52,18 @@ re : re '|' series
; ;
series : series singleton series : series singleton
{ $1->AppendMachine($2); } { $1->AppendMachine($2); $$ = $1; }
| singleton | singleton
; ;
singleton : singleton '*' singleton : singleton '*'
{ $1->MakeClosure(); } { $1->MakeClosure(); $$ = $1; }
| singleton '+' | singleton '+'
{ $1->MakePositiveClosure(); } { $1->MakePositiveClosure(); $$ = $1; }
| singleton '?' | singleton '?'
{ $1->MakeOptional(); } { $1->MakeOptional(); $$ = $1; }
| singleton '{' TOK_NUMBER ',' TOK_NUMBER '}' | singleton '{' TOK_NUMBER ',' TOK_NUMBER '}'
{ {
@ -95,6 +97,8 @@ singleton : singleton '*'
$1->MakeClosure(); $1->MakeClosure();
else else
$1->MakeRepl($3, NO_UPPER_BOUND); $1->MakeRepl($3, NO_UPPER_BOUND);
$$ = $1;
} }
| singleton '{' TOK_NUMBER '}' | singleton '{' TOK_NUMBER '}'
@ -239,6 +243,7 @@ string : string TOK_CHAR
// of "escaping" out of insensitivity // of "escaping" out of insensitivity
// if needed. // if needed.
$1->AppendState(new zeek::detail::NFA_State($2, zeek::detail::rem->EC())); $1->AppendState(new zeek::detail::NFA_State($2, zeek::detail::rem->EC()));
$$ = $1;
} }
| |

View file

@ -1,4 +1,4 @@
# @TEST-EXEC: ASAN_OPTIONS="$ASAN_OPTIONS,detect_leaks=0" zeek -b %INPUT # @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff .stdout # @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff .stdout
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr