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
20
regint.h
20
regint.h
|
@ -154,13 +154,18 @@
|
|||
#ifdef RUBY
|
||||
|
||||
# define CHECK_INTERRUPT_IN_MATCH_AT do { \
|
||||
msa->counter++; \
|
||||
if (msa->counter >= 128) { \
|
||||
msa->counter = 0; \
|
||||
rb_reg_check_timeout(reg, &msa->end_time); \
|
||||
rb_thread_check_ints(); \
|
||||
} \
|
||||
msa->counter++; \
|
||||
if (msa->counter >= 128) { \
|
||||
msa->counter = 0; \
|
||||
if (rb_reg_timeout_p(reg, &msa->end_time)) { \
|
||||
goto timeout; \
|
||||
} \
|
||||
rb_thread_check_ints(); \
|
||||
} \
|
||||
} while(0)
|
||||
# define HANDLE_REG_TIMEOUT_IN_MATCH_AT do { \
|
||||
rb_reg_raise_timeout(); \
|
||||
} while (0)
|
||||
# define onig_st_init_table st_init_table
|
||||
# define onig_st_init_table_with_size st_init_table_with_size
|
||||
# define onig_st_init_numtable st_init_numtable
|
||||
|
@ -996,7 +1001,8 @@ extern int onig_st_insert_strend(hash_table_type* table, const UChar* str_key, c
|
|||
#ifdef RUBY
|
||||
extern size_t onig_memsize(const regex_t *reg);
|
||||
extern size_t onig_region_memsize(const struct re_registers *regs);
|
||||
void rb_reg_check_timeout(regex_t *reg, void *end_time);
|
||||
bool rb_reg_timeout_p(regex_t *reg, void *end_time);
|
||||
NORETURN(void rb_reg_raise_timeout(void));
|
||||
#endif
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue