From fbac7ddfe5fe25427224e9715c122160178f47a2 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 23 Nov 2011 13:29:48 -0800 Subject: [PATCH] Call FETCH once when chomping a tied ref --- pp.c | 2 +- t/op/gmagic.t | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pp.c b/pp.c index 9325d0e..16794ad 100644 --- a/pp.c +++ b/pp.c @@ -882,7 +882,7 @@ S_do_chomp(pTHX_ SV *retval, SV *sv, bool chomping) SvIVX(retval) += rs_charlen; } } - s = SvPV_force_nolen(sv); + s = SvPV_force_nomg_nolen(sv); SvCUR_set(sv, len); *SvEND(sv) = '\0'; SvNIOK_off(sv); diff --git a/t/op/gmagic.t b/t/op/gmagic.t index 9abde47..daebae4 100644 --- a/t/op/gmagic.t +++ b/t/op/gmagic.t @@ -56,6 +56,11 @@ ok($s eq *strat, 'Assignment should not ignore magic when the last thing assigned was a glob'); expected_tie_calls(tied $c, 1, 1); +package o { use overload '""' => sub { "foo\n" } } +$c = bless [], o::; +chomp $c; +expected_tie_calls(tied $c, 1, 2, 'chomping a ref'); + # autovivication of aelem, helem, of rv2sv combined with get-magic { my $true = 1; -- 2.7.4