Many thanks!

Tim.

On Fri, May 03, 2002 at 09:12:10PM +0100, Dave Mitchell wrote:
> This patch fixes the memory leak in
>     local $tied[n]
> and
>     local $tied{foo}
> 
> The problem was that the newly created undef SV that is normally stored as
> the new value of the element doesn't actually get stored in the array/hash
> when there's tying going on. So it doesn't get freed at the end of the
> block.
> 
> Dave.
> 
> --- scope.c-  Fri May  3 20:27:11 2002
> +++ scope.c   Fri May  3 20:47:10 2002
> @@ -206,6 +206,12 @@ S_save_scalar_at(pTHX_ SV **sptr)
>       PL_localizing = 1;
>       SvSETMAGIC(sv);
>       PL_localizing = 0;
> +     /* If we're localizing a tied array/hash element, this new sv
> +      * won't actually be stored in the array/hash - so it won't get
> +      * reaped when the localize ends. Ensure it gets reaped by
> +      * mortifying it instead. DAPM */
> +     if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
> +         sv_2mortal(sv);
>      }
>      return sv;
>  }

Reply via email to