[llvm] Fix crash in install_bad_alloc_error_handler (PR #83160)

Fabian Schiebel via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 09:44:27 PST 2024


https://github.com/fabianbs96 created https://github.com/llvm/llvm-project/pull/83160

Fixes #83040

>From 27c72eb3cef62585f14e9a3480c4412f049ae563 Mon Sep 17 00:00:00 2001
From: Fabian Schiebel <fabian.schiebel at iem.fraunhofer.de>
Date: Tue, 27 Feb 2024 18:42:55 +0100
Subject: [PATCH] fix: Make the assert in install_bad_alloc_error_handler
 reference the correct variable

---
 llvm/lib/Support/ErrorHandling.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index b8b3b7424ac6b1..d2d3dcc2f478c5 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -130,7 +130,8 @@ void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
 #if LLVM_ENABLE_THREADS == 1
   std::lock_guard<std::mutex> Lock(BadAllocErrorHandlerMutex);
 #endif
-  assert(!ErrorHandler && "Bad alloc error handler already registered!\n");
+  assert(!BadAllocErrorHandler &&
+         "Bad alloc error handler already registered!\n");
   BadAllocErrorHandler = handler;
   BadAllocErrorHandlerUserData = user_data;
 }



More information about the llvm-commits mailing list