mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
MachObjectFile: Don't leak on error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a757e93626
commit
782fdcefa5
@ -1599,21 +1599,23 @@ void MachOObjectFile::ReadULEB128s(uint64_t Index,
|
||||
ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) {
|
||||
StringRef Magic = Buffer->getBuffer().slice(0, 4);
|
||||
error_code ec;
|
||||
ObjectFile *Ret;
|
||||
OwningPtr<ObjectFile> Ret;
|
||||
if (Magic == "\xFE\xED\xFA\xCE")
|
||||
Ret = new MachOObjectFile(Buffer, false, false, ec);
|
||||
Ret.reset(new MachOObjectFile(Buffer, false, false, ec));
|
||||
else if (Magic == "\xCE\xFA\xED\xFE")
|
||||
Ret = new MachOObjectFile(Buffer, true, false, ec);
|
||||
Ret.reset(new MachOObjectFile(Buffer, true, false, ec));
|
||||
else if (Magic == "\xFE\xED\xFA\xCF")
|
||||
Ret = new MachOObjectFile(Buffer, false, true, ec);
|
||||
Ret.reset(new MachOObjectFile(Buffer, false, true, ec));
|
||||
else if (Magic == "\xCF\xFA\xED\xFE")
|
||||
Ret = new MachOObjectFile(Buffer, true, true, ec);
|
||||
else
|
||||
Ret.reset(new MachOObjectFile(Buffer, true, true, ec));
|
||||
else {
|
||||
delete Buffer;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ec)
|
||||
return NULL;
|
||||
return Ret;
|
||||
return Ret.take();
|
||||
}
|
||||
|
||||
} // end namespace object
|
||||
|
Loading…
x
Reference in New Issue
Block a user