[llvm] Revert "Revert "Fix memory leak in Offloading API" (#161465)" (PR #161573)

David Salinas via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 12:57:13 PDT 2025


https://github.com/david-salinas created https://github.com/llvm/llvm-project/pull/161573

This reverts commit d392563433316e310edacf35a40fb2f9aa477acc.

>From 78d5ad84b49674cbae4772170138150d602803e3 Mon Sep 17 00:00:00 2001
From: david-salinas <dsalinas at amd.com>
Date: Wed, 1 Oct 2025 19:35:52 +0000
Subject: [PATCH] Revert "Revert "Fix memory leak in Offloading API" (#161465)"

This reverts commit d392563433316e310edacf35a40fb2f9aa477acc.
---
 llvm/lib/Object/OffloadBundle.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp
index 0dd378e65fd81..a6a9628acddcc 100644
--- a/llvm/lib/Object/OffloadBundle.cpp
+++ b/llvm/lib/Object/OffloadBundle.cpp
@@ -120,14 +120,15 @@ 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<OffloadBundleFatBin> TheBundle(
+      new OffloadBundleFatBin(Buf, FileName));
 
   // Read the Bundle Entries
   Error Err = TheBundle->readEntries(Buf.getBuffer(), SectionOffset);
   if (Err)
     return Err;
 
-  return std::unique_ptr<OffloadBundleFatBin>(TheBundle);
+  return TheBundle;
 }
 
 Error OffloadBundleFatBin::extractBundle(const ObjectFile &Source) {



More information about the llvm-commits mailing list