From 46f83f188ea8eefc9e3704a9c4ac799f7c0a9c0d Mon Sep 17 00:00:00 2001 From: mikit <37488201+m1kit@users.noreply.github.com> Date: Tue, 15 Apr 2025 22:08:31 +0900 Subject: [PATCH] UB 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 --- tools/clang/lib/CodeGen/CodeGenTypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clang/lib/CodeGen/CodeGenTypes.cpp b/tools/clang/lib/CodeGen/CodeGenTypes.cpp index 82328c8fb5..756d36c3bb 100644 --- a/tools/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/tools/clang/lib/CodeGen/CodeGenTypes.cpp @@ -47,7 +47,7 @@ CodeGenTypes::~CodeGenTypes() { for (llvm::FoldingSet::iterator I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; ) - delete &*I++; + ::operator delete(&*I++); } void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,