[llvm-branch-commits] [compiler-rt] [sanitizer] Add TryMemCpy (PR #112668)

Vitaly Buka via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 17 15:47:52 PDT 2024


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/112668

>From 9571c266d478f2cb49a8005b0d19f40b3de72052 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Thu, 17 Oct 2024 15:47:37 -0700
Subject: [PATCH] rebase

Created using spr 1.3.4
---
 compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp    | 2 ++
 compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp | 1 +
 2 files changed, 3 insertions(+)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
index 6459c64985faab..e1117c1bec33fa 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -327,6 +327,8 @@ bool IsAccessibleMemoryRange(uptr beg, uptr size) {
 }
 
 bool TryMemCpy(void *dest, const void *src, uptr n) {
+  if (!n)
+    return true;
   int fds[2];
   CHECK_EQ(0, pipe(fds));
 
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp
index 9e463796b2c678..03a841a6f438cb 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp
@@ -16,6 +16,7 @@
 #  include <pthread.h>
 #  include <sys/mman.h>
 
+#  include <algorithm>
 #  include <numeric>
 
 #  include "gtest/gtest.h"



More information about the llvm-branch-commits mailing list