diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp index 8dfc26508bcc..1d1dafdc8f42 100644 --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -38,8 +38,10 @@ section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const { } ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) { - if (!Object || Object->getBufferSize() < 64) + if (Object->getBufferSize() < 64) { + delete Object; return 0; + } sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer()); switch (Type) { @@ -47,6 +49,7 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) { case sys::fs::file_magic::bitcode: case sys::fs::file_magic::archive: case sys::fs::file_magic::macho_universal_binary: + delete Object; return 0; case sys::fs::file_magic::elf_relocatable: case sys::fs::file_magic::elf_executable: