Blob Blame History Raw
From a3ff80c12c16886edf9acdd3d172798e50defdb3 Mon Sep 17 00:00:00 2001
From: Eric Brine <ikegami@adaelis.com>
Date: Mon, 18 Jun 2012 14:56:32 -0400
Subject: [PATCH] RT#113730 - $@ should be cleared on "do" IO error.

---
 pp_ctl.c  |  1 +
 t/op/do.t | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/pp_ctl.c b/pp_ctl.c
index b414e81..437bc8f 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3928,6 +3928,7 @@ PP(pp_require)
 	    DIE(aTHX_ "Can't locate %s", name);
 	}
 
+	CLEAR_ERRSV();
 	RETPUSHUNDEF;
     }
     else
diff --git a/t/op/do.t b/t/op/do.t
index 93d3f73..c5a5905 100644
--- a/t/op/do.t
+++ b/t/op/do.t
@@ -286,4 +286,16 @@ SKIP: {
   is($w, undef, 'do STRING does not propagate warning hints');
 }
 
+# RT#113730 - $@ should be cleared on IO error.
+{
+    $@ = "should not see";
+    $! = 0;
+    my $rv = do("some nonexistent file");
+    my $saved_error = $@;
+    my $saved_errno = $!;
+    ok(!$rv,          "do returns false on io errror");
+    ok(!$saved_error, "\$\@ not set on io error");
+    ok($saved_errno,  "\$! set on io error");
+}
+
 done_testing();
-- 
1.7.11.4