-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataflowSanitizer] Use nullptr instead of NULL or 0 #85986
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: LL (matrixificiation) ChangesFull diff: https://github.com/llvm/llvm-project/pull/85986.diff 1 Files Affected:
diff --git a/compiler-rt/lib/dfsan/dfsan_allocator.cpp b/compiler-rt/lib/dfsan/dfsan_allocator.cpp
index 63475f434cd100..d382501eb991a5 100644
--- a/compiler-rt/lib/dfsan/dfsan_allocator.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_allocator.cpp
@@ -91,16 +91,48 @@ void DFsanThreadLocalMallocStorage::CommitBack() {
static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
if (size > max_malloc_size) {
if (AllocatorMayReturnNull()) {
- Report("WARNING: DataflowSanitizer failed to allocate 0x%zx bytes\n",
- size);
- return nullptr;
- }
- BufferedStackTrace stack;
- ReportAllocationSizeTooBig(size, max_malloc_size, &stack);
- }
- if (UNLIKELY(IsRssLimitExceeded())) {
- if (AllocatorMayReturnNull())
- return nullptr;
+ Report("WARNING: DataflowSanitizer failed to allocate 0x%zx bytes\n",
+ size);
+ return nullptr;
+}
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
+if (!p)
+ return nullptr;
+
+if (!beg)
+ return nullptr;
+
+if (!b)
+ return nullptr;
+
+if (!ptr)
+ return SetErrnoOnNull(DFsanAllocate(size, sizeof(u64), false /*zeroise*/));
+if (size == 0) {
+ dfsan_deallocate(ptr);
+ return nullptr;
+}
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
+if (AllocatorMayReturnNull())
+ return nullptr;
+
BufferedStackTrace stack;
ReportRssLimitExceeded(&stack);
}
|
|
You can test this locally with the following command:git-clang-format --diff 891172d9be01dd7c7e5298f2d8fdb143add448da c1142da8557b5c32eef0b0122fee4552911b48ea -- compiler-rt/lib/dfsan/dfsan_allocator.cpp View the diff from clang-format here.diff --git a/compiler-rt/lib/dfsan/dfsan_allocator.cpp b/compiler-rt/lib/dfsan/dfsan_allocator.cpp
index d382501eb9..282e523345 100644
--- a/compiler-rt/lib/dfsan/dfsan_allocator.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_allocator.cpp
@@ -91,47 +91,48 @@ void DFsanThreadLocalMallocStorage::CommitBack() {
static void *DFsanAllocate(uptr size, uptr alignment, bool zeroise) {
if (size > max_malloc_size) {
if (AllocatorMayReturnNull()) {
- Report("WARNING: DataflowSanitizer failed to allocate 0x%zx bytes\n",
- size);
- return nullptr;
-}
+ Report("WARNING: DataflowSanitizer failed to allocate 0x%zx bytes\n",
+ size);
+ return nullptr;
+ }
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
-if (!p)
- return nullptr;
+ if (!p)
+ return nullptr;
-if (!beg)
- return nullptr;
+ if (!beg)
+ return nullptr;
-if (!b)
- return nullptr;
+ if (!b)
+ return nullptr;
-if (!ptr)
- return SetErrnoOnNull(DFsanAllocate(size, sizeof(u64), false /*zeroise*/));
-if (size == 0) {
- dfsan_deallocate(ptr);
- return nullptr;
-}
+ if (!ptr)
+ return SetErrnoOnNull(
+ DFsanAllocate(size, sizeof(u64), false /*zeroise*/));
+ if (size == 0) {
+ dfsan_deallocate(ptr);
+ return nullptr;
+ }
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
-if (AllocatorMayReturnNull())
- return nullptr;
+ if (AllocatorMayReturnNull())
+ return nullptr;
BufferedStackTrace stack;
ReportRssLimitExceeded(&stack);
|
No description provided.