mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Fix memory leak in stk_base when Regexp timeout
[Bug #20228] If rb_reg_check_timeout raises a Regexp::TimeoutError, then the stk_base will leak.
This commit is contained in:
parent
a4e4e3b1f1
commit
1c120efe02
3 changed files with 31 additions and 12 deletions
|
@ -2293,7 +2293,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
UChar *pkeep;
|
||||
char *alloca_base;
|
||||
char *xmalloc_base = NULL;
|
||||
OnigStackType *stk_alloc, *stk_base, *stk, *stk_end;
|
||||
OnigStackType *stk_alloc, *stk_base = NULL, *stk, *stk_end;
|
||||
OnigStackType *stkp; /* used as any purpose. */
|
||||
OnigStackIndex si;
|
||||
OnigStackIndex *repeat_stk;
|
||||
|
@ -4202,6 +4202,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
STACK_SAVE;
|
||||
xfree(xmalloc_base);
|
||||
return ONIGERR_UNEXPECTED_BYTECODE;
|
||||
|
||||
timeout:
|
||||
xfree(xmalloc_base);
|
||||
xfree(stk_base);
|
||||
HANDLE_REG_TIMEOUT_IN_MATCH_AT;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue