This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restore errno after having read $^E (like for $!)
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 19 Nov 2003 17:21:50 +0000 (17:21 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 19 Nov 2003 17:21:50 +0000 (17:21 +0000)
to preserve errno from unfortunate side-effects.

p4raw-id: //depot/perl@21743

mg.c

diff --git a/mg.c b/mg.c
index 245acd7..494a4e2 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -623,8 +623,12 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
                  SetLastError(dwErr);
             }
 #else
-            sv_setnv(sv, (NV)errno);
-            sv_setpv(sv, errno ? Strerror(errno) : "");
+            {
+                int saveerrno = errno;
+                sv_setnv(sv, (NV)errno);
+                sv_setpv(sv, errno ? Strerror(errno) : "");
+                errno = saveerrno;
+            }
 #endif
 #endif
 #endif