[obj2yaml] Fix ASAN bot failure

I was leaking out of a unique_ptr, should have just kept it in the unique_ptr.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12738/steps/check-llvm%20asan/logs/stdio

llvm-svn: 269336
This commit is contained in:
Chris Bieneman 2016-05-12 19:57:07 +00:00
parent 3f19f1ad66
commit 635b6b12b0

View File

@ -21,10 +21,10 @@ class MachODumper {
public:
MachODumper(const object::MachOObjectFile &O) : Obj(O) {}
Expected<MachOYAML::Object *> dump();
Expected<std::unique_ptr<MachOYAML::Object> > dump();
};
Expected<MachOYAML::Object *> MachODumper::dump() {
Expected<std::unique_ptr<MachOYAML::Object> > MachODumper::dump() {
auto Y = make_unique<MachOYAML::Object>();
Y->Header.magic = Obj.getHeader().magic;
Y->Header.cputype = Obj.getHeader().cputype;
@ -34,12 +34,12 @@ Expected<MachOYAML::Object *> MachODumper::dump() {
Y->Header.sizeofcmds = Obj.getHeader().sizeofcmds;
Y->Header.flags = Obj.getHeader().flags;
return Y.release();
return std::move(Y);
}
Error macho2yaml(raw_ostream &Out, const object::MachOObjectFile &Obj) {
MachODumper Dumper(Obj);
Expected<MachOYAML::Object *> YAML = Dumper.dump();
Expected<std::unique_ptr<MachOYAML::Object> > YAML = Dumper.dump();
if (!YAML)
return YAML.takeError();