[clang] [CodeGen] Fix new-delete-type-mismatch in ~CodeGenTypes() (PR #135787)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 15 06:32:40 PDT 2025
https://github.com/m1kit created https://github.com/llvm/llvm-project/pull/135787
It is undefined behavior to use `delete` expression on something which was not created with corresponding `new` expression. Switching to explicit global `operator delete()` call to match with `operator new()` call at `CGFunctionInfo::create()`.
This issue is raised by Chromium ClusterFuzz, with ASan enabled. https://crbug.com/410141973
>From 15631133faed63a1c4bf7b3c9076629985e48bf9 Mon Sep 17 00:00:00 2001
From: mikit <37488201+m1kit at users.noreply.github.com>
Date: Tue, 15 Apr 2025 22:32:24 +0900
Subject: [PATCH] [CodeGen] Fix new-delete-type-mismatch in ~CodeGenTypes()
It is undefined behavior to use `delete` expression on something
which was not created with corresponding `new` expression.
Switching to explicit global `operator delete()` call to match with
`operator new()` call at `CGFunctionInfo::create()`.
This issue is raised by Chromium ClusterFuzz, with ASan enabled.
https://crbug.com/410141973
---
clang/lib/CodeGen/CodeGenTypes.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index b94c11802a268..dec3b087b107f 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -41,7 +41,7 @@ CodeGenTypes::CodeGenTypes(CodeGenModule &cgm)
CodeGenTypes::~CodeGenTypes() {
for (llvm::FoldingSet<CGFunctionInfo>::iterator
I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
- delete &*I++;
+ operator delete(&*I++);
}
CGCXXABI &CodeGenTypes::getCXXABI() const { return getCGM().getCXXABI(); }
More information about the cfe-commits
mailing list