Skip to content

Commit bdea159

Browse files
Revert "Revert "Fix memory leak in Offloading API" (#161465)" (#161573)
This reverts commit d392563.
1 parent 5f0f497 commit bdea159

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Object/OffloadBundle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,15 @@ OffloadBundleFatBin::create(MemoryBufferRef Buf, uint64_t SectionOffset,
120120
if (identify_magic(Buf.getBuffer()) != file_magic::offload_bundle)
121121
return errorCodeToError(object_error::parse_failed);
122122

123-
OffloadBundleFatBin *TheBundle = new OffloadBundleFatBin(Buf, FileName);
123+
std::unique_ptr<OffloadBundleFatBin> TheBundle(
124+
new OffloadBundleFatBin(Buf, FileName));
124125

125126
// Read the Bundle Entries
126127
Error Err = TheBundle->readEntries(Buf.getBuffer(), SectionOffset);
127128
if (Err)
128129
return Err;
129130

130-
return std::unique_ptr<OffloadBundleFatBin>(TheBundle);
131+
return std::move(TheBundle);
131132
}
132133

133134
Error OffloadBundleFatBin::extractBundle(const ObjectFile &Source) {

0 commit comments

Comments
 (0)