This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Bundler] Fix for a potential memory leak [NFC]
ClosedPublic

Authored by sdmitriev on Sep 10 2019, 2:08 PM.

Details

Summary

Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626).

Diff Detail

Repository
rL LLVM

Event Timeline

sdmitriev created this revision.Sep 10 2019, 2:08 PM
Hahnfeld accepted this revision.Sep 11 2019, 8:01 AM

LG iff the following is correct: The leak is when dyn_cast can't cast and returns null, right? If so, please add into the summary (and do so for future revisions, it will speed up review).

This revision is now accepted and ready to land.Sep 11 2019, 8:01 AM

LG iff the following is correct: The leak is when dyn_cast can't cast and returns null, right? If so, please add into the summary (and do so for future revisions, it will speed up review).

Yes, exactly. Memory leak is happening when *BinaryOrErr cannot be casted to an ObjectFile. In this case BinaryOrErr releases ownership of the binary, but no one is taking it. I will add this to the summary.

sdmitriev edited the summary of this revision. (Show Details)Sep 11 2019, 8:35 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 11 2019, 9:04 AM