[llvm-objdump] Fix memory leaks in macho dump
ClosedPublic

Authored by fjricci on Sep 12 2017, 10:21 AM.

Details

Summary

Detected by LeakSanitizer for Darwin

Diff Detail

Repository
rL LLVM
fjricci created this revision.Sep 12 2017, 10:21 AM
compnerd accepted this revision.Sep 12 2017, 10:51 AM
compnerd added inline comments.
tools/llvm-objdump/MachODump.cpp
6050 ↗(On Diff #114862)

Ugh, that is a confusing call. xar_extract_tobuffersz will allocate the buffer, so, yeah, the allocation there was unnecessary.

This revision is now accepted and ready to land.Sep 12 2017, 10:51 AM
fjricci updated this revision to Diff 115035.Sep 13 2017, 6:57 AM

Only delete buffer if xar_extract_tobuffersz succeeds

This revision was automatically updated to reflect the committed changes.
dblaikie added inline comments.
llvm/trunk/tools/llvm-objdump/MachODump.cpp
5884

Any chance of an RAII API for this resource, to avoid the accident-prone manual cleanup/free?