From: Abhijit Menon-Sen <ams@wiw.org>
Date: Tue, 17 Sep 2002 18:09:32 +0000 (+0000)
Subject: Fix #17375 (rcatline didn't work on a formerly-defined undef) by
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b5e58c4e3614e505a895c6ac7f709db82f8f7f4;p=p5sagit%2Fp5-mst-13.2.git

Fix #17375 (rcatline didn't work on a formerly-defined undef) by
checking for SvOK in do_readline().

p4raw-id: //depot/perl@17910
---

diff --git a/pp_hot.c b/pp_hot.c
index 2895069..f0d3e98 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1484,10 +1484,14 @@ Perl_do_readline(pTHX)
 	tmplen = SvLEN(sv);	/* remember if already alloced */
 	if (!tmplen)
 	    Sv_Grow(sv, 80);	/* try short-buffering it */
-	if (type == OP_RCATLINE)
+	offset = 0;
+	if (type == OP_RCATLINE && SvOK(sv)) {
+	    if (!SvPOK(sv)) {
+		STRLEN n_a;
+		(void)SvPV_force(sv, n_a);
+	    }
 	    offset = SvCUR(sv);
-	else
-	    offset = 0;
+	}
     }
     else {
 	sv = sv_2mortal(NEWSV(57, 80));
diff --git a/t/op/gv.t b/t/op/gv.t
index 9ce1135..9b347d3 100755
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -11,7 +11,7 @@ BEGIN {
 
 use warnings;
 
-print "1..47\n";
+print "1..48\n";
 
 # type coersion on assignment
 $foo = 'foo';
@@ -208,5 +208,15 @@ print $j[0] == 1 ? "ok 43\n" : "not ok 43\n";
     print $w =~ /Prototype mismatch/ ? "ok 47\n" : "not ok 47\n# $w";
 }
 
+{
+    # [17375] rcatline to formerly-defined undef was broken. Fixed in
+    # do_readline by checking SvOK. AMS, 20020918
+    my $x = "not ";
+    $x  = undef;
+    $x .= <DATA>;
+    print $x;
+}
+
 __END__
 ok 44
+ok 48