Call FETCH once when chomping a tied ref
authorFather Chrysostomos <sprout@cpan.org>
Wed, 23 Nov 2011 21:29:48 +0000 (13:29 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 24 Nov 2011 09:45:29 +0000 (01:45 -0800)
pp.c
t/op/gmagic.t

diff --git a/pp.c b/pp.c
index 9325d0e..16794ad 100644 (file)
--- 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);
index 9abde47..daebae4 100644 (file)
@@ -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;