[llvm] r214313 - llvm-uselistorder: Fix memory leak from r214125
David Blaikie
dblaikie at gmail.com
Wed Jul 30 12:10:18 PDT 2014
On Wed, Jul 30, 2014 at 9:50 AM, Duncan P. N. Exon Smith
<dexonsmith at apple.com> wrote:
> Author: dexonsmith
> Date: Wed Jul 30 11:50:22 2014
> New Revision: 214313
>
> URL: http://llvm.org/viewvc/llvm-project?rev=214313&view=rev
> Log:
> llvm-uselistorder: Fix memory leak from r214125
>
> Turns out `parseBitcodeFile()` does *not* take ownership of the buffer.
> This was already clear in the header docs, but I obviously didn't read
> them (having noticed that it gets stored in a `unique_ptr<>`).
>
> Modified:
> llvm/trunk/tools/llvm-uselistorder/llvm-uselistorder.cpp
>
> Modified: llvm/trunk/tools/llvm-uselistorder/llvm-uselistorder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-uselistorder/llvm-uselistorder.cpp?rev=214313&r1=214312&r2=214313&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-uselistorder/llvm-uselistorder.cpp (original)
> +++ llvm/trunk/tools/llvm-uselistorder/llvm-uselistorder.cpp Wed Jul 30 11:50:22 2014
> @@ -137,7 +137,7 @@ std::unique_ptr<Module> TempFile::readBi
> }
>
> std::unique_ptr<MemoryBuffer> Buffer = std::move(BufferOr.get());
> - ErrorOr<Module *> ModuleOr = parseBitcodeFile(Buffer.release(), Context);
> + ErrorOr<Module *> ModuleOr = parseBitcodeFile(Buffer.get(), Context);
If someone's sufficiently bored we could change parseBitcodeFile to
take a reference instead of a pointer - makes it clearer that there's
no transfer of ownership (or nullness).
> if (!ModuleOr) {
> DEBUG(dbgs() << "error: " << ModuleOr.getError().message() << "\n");
> return nullptr;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list