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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-binary-utilities

Author: David Salinas (david-salinas)

<details>
<summary>Changes</summary>

This reverts commit d392563433316e310edacf35a40fb2f9aa477acc.

---
Full diff: https://github.com/llvm/llvm-project/pull/161573.diff


1 Files Affected:

- (modified) llvm/lib/Object/OffloadBundle.cpp (+3-2) 


``````````diff
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) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/161573


More information about the llvm-commits mailing list