diff --git a/av.c b/av.c index afac896dda8d..3d55de9d9612 100644 --- a/av.c +++ b/av.c @@ -170,12 +170,6 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp, to_null += newmax - *maxp; *maxp = newmax; - /* See GH#18014 for discussion of when this might be needed: */ - if (av == PL_curstack) { /* Oops, grew stack (via av_store()?) */ - PL_stack_sp = *allocp + (PL_stack_sp - PL_stack_base); - PL_stack_base = *allocp; - PL_stack_max = PL_stack_base + newmax; - } } else { /* there is no SV* array yet */ *maxp = key < 3 ? 3 : key; { diff --git a/scope.c b/scope.c index 8119c4ac632e..f7e2a4813d5b 100644 --- a/scope.c +++ b/scope.c @@ -56,6 +56,11 @@ Perl_stack_grow(pTHX_ SV **sp, SV **p, SSize_t n) Perl_croak(aTHX_ "Out of memory during stack extend"); av_extend(PL_curstack, current + n + extra); + + PL_stack_sp = AvALLOC(PL_curstack) + (PL_stack_sp - PL_stack_base); + PL_stack_base = AvALLOC(PL_curstack); + PL_stack_max = PL_stack_base + AvMAX(PL_curstack); + #ifdef DEBUGGING PL_curstackinfo->si_stack_hwm = current + n + extra; #endif