mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Just free compiled pattern if no space is used
This commit is contained in:
parent
53f5fc4236
commit
73f45e5e96
1 changed files with 8 additions and 6 deletions
14
regcomp.c
14
regcomp.c
|
@ -142,8 +142,13 @@ bitset_on_num(BitSetRef bs)
|
|||
static void
|
||||
onig_reg_resize(regex_t *reg)
|
||||
{
|
||||
resize:
|
||||
if (reg->alloc > reg->used) {
|
||||
do {
|
||||
if (!reg->used) {
|
||||
xfree(reg->p);
|
||||
reg->alloc = 0;
|
||||
reg->p = 0;
|
||||
}
|
||||
else if (reg->alloc > reg->used) {
|
||||
unsigned char *new_ptr = xrealloc(reg->p, reg->used);
|
||||
// Skip the right size optimization if memory allocation fails
|
||||
if (new_ptr) {
|
||||
|
@ -151,10 +156,7 @@ onig_reg_resize(regex_t *reg)
|
|||
reg->p = new_ptr;
|
||||
}
|
||||
}
|
||||
if (reg->chain) {
|
||||
reg = reg->chain;
|
||||
goto resize;
|
||||
}
|
||||
} while ((reg = reg->chain) != 0);
|
||||
}
|
||||
|
||||
extern int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue