From aa234bf11b661d960d47368ef9de61641ceebd56 Mon Sep 17 00:00:00 2001 From: david-salinas Date: Tue, 30 Sep 2025 19:34:29 +0000 Subject: [PATCH 1/2] Fix memory leak in Offloading API --- llvm/lib/Object/OffloadBundle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp index 0dd378e65fd81..7c84e9b92032d 100644 --- a/llvm/lib/Object/OffloadBundle.cpp +++ b/llvm/lib/Object/OffloadBundle.cpp @@ -120,14 +120,14 @@ OffloadBundleFatBin::create(MemoryBufferRef Buf, uint64_t SectionOffset, if (identify_magic(Buf.getBuffer()) != file_magic::offload_bundle) return errorCodeToError(object_error::parse_failed); - OffloadBundleFatBin *TheBundle = new OffloadBundleFatBin(Buf, FileName); + std::unique_ptr TheBundle(new OffloadBundleFatBin(Buf, FileName)); // Read the Bundle Entries Error Err = TheBundle->readEntries(Buf.getBuffer(), SectionOffset); if (Err) return Err; - return std::unique_ptr(TheBundle); + return TheBundle; } Error OffloadBundleFatBin::extractBundle(const ObjectFile &Source) { From 341f10dfc19a84dfed45d97e4d9c2873d76069dd Mon Sep 17 00:00:00 2001 From: david-salinas Date: Tue, 30 Sep 2025 20:34:53 +0000 Subject: [PATCH 2/2] fix clang-format errors --- llvm/lib/Object/OffloadBundle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp index 7c84e9b92032d..a6a9628acddcc 100644 --- a/llvm/lib/Object/OffloadBundle.cpp +++ b/llvm/lib/Object/OffloadBundle.cpp @@ -120,7 +120,8 @@ OffloadBundleFatBin::create(MemoryBufferRef Buf, uint64_t SectionOffset, if (identify_magic(Buf.getBuffer()) != file_magic::offload_bundle) return errorCodeToError(object_error::parse_failed); - std::unique_ptr TheBundle(new OffloadBundleFatBin(Buf, FileName)); + std::unique_ptr TheBundle( + new OffloadBundleFatBin(Buf, FileName)); // Read the Bundle Entries Error Err = TheBundle->readEntries(Buf.getBuffer(), SectionOffset);