about summary refs log tree commit diff
path: root/absl/debugging/internal/address_is_readable.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/debugging/internal/address_is_readable.cc')
-rw-r--r--absl/debugging/internal/address_is_readable.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/absl/debugging/internal/address_is_readable.cc b/absl/debugging/internal/address_is_readable.cc
index f45e59b3836a..65376063669f 100644
--- a/absl/debugging/internal/address_is_readable.cc
+++ b/absl/debugging/internal/address_is_readable.cc
@@ -35,10 +35,12 @@ ABSL_NAMESPACE_END
 #include <fcntl.h>
 #include <sys/syscall.h>
 #include <unistd.h>
+
 #include <atomic>
 #include <cerrno>
 #include <cstdint>
 
+#include "absl/base/internal/errno_saver.h"
 #include "absl/base/internal/raw_logging.h"
 
 namespace absl {
@@ -67,7 +69,7 @@ static void Unpack(uint64_t x, int *pid, int *read_fd, int *write_fd) {
 // This is a namespace-scoped variable for correct zero-initialization.
 static std::atomic<uint64_t> pid_and_fds;  // initially 0, an invalid pid.
 bool AddressIsReadable(const void *addr) {
-  int save_errno = errno;
+  absl::base_internal::ErrnoSaver errno_saver;
   // We test whether a byte is readable by using write().  Normally, this would
   // be done via a cached file descriptor to /dev/null, but linux fails to
   // check whether the byte is readable when the destination is /dev/null, so
@@ -126,7 +128,6 @@ bool AddressIsReadable(const void *addr) {
                                           std::memory_order_relaxed);
     }
   } while (errno == EBADF);
-  errno = save_errno;
   return bytes_written == 1;
 }