diff --git a/op.c b/op.c index ae0d6e8c5c7..ecda97e2b50 100644 --- a/op.c +++ b/op.c @@ -305,6 +305,9 @@ Perl_Slab_Free(pTHX_ void *op) # ifndef PERL_SLAB_SIZE # define PERL_SLAB_SIZE 64 # endif +# ifndef PERL_MAX_SLAB_SIZE +# define PERL_MAX_SLAB_SIZE 2048 +# endif /* rounds up to nearest pointer */ # define SIZE_TO_PSIZE(x) (((x) + sizeof(I32 *) - 1)/sizeof(I32 *)) @@ -391,7 +394,9 @@ Perl_Slab_Alloc(pTHX_ size_t sz) /* Create a new slab. Make this one twice as big. */ slot = slab2->opslab_first; while (slot->opslot_next) slot = slot->opslot_next; - slab2 = S_new_slab(aTHX_ DIFF(slab2, slot)*2); + slab2 = S_new_slab(aTHX_ DIFF(slab2, slot)*2 > PERL_MAX_SLAB_SIZE + ? PERL_MAX_SLAB_SIZE + : DIFF(slab2, slot)*2); slab2->opslab_next = slab->opslab_next; slab->opslab_next = slab2; }