mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Delete the buffer in createObjectFile if it fails.
The Binary constructor takes ownership of the memory buffer. This is a fairly unfortunate interface, but for now make createObjectFile consistent with it by also deleting the buffer if it fails. Fixes a leak in llvm-ar found by the valgrind bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
36f5ac198f
commit
7976842791
@ -38,8 +38,10 @@ section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
|
ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
|
||||||
if (!Object || Object->getBufferSize() < 64)
|
if (Object->getBufferSize() < 64) {
|
||||||
|
delete Object;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer());
|
sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer());
|
||||||
switch (Type) {
|
switch (Type) {
|
||||||
@ -47,6 +49,7 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
|
|||||||
case sys::fs::file_magic::bitcode:
|
case sys::fs::file_magic::bitcode:
|
||||||
case sys::fs::file_magic::archive:
|
case sys::fs::file_magic::archive:
|
||||||
case sys::fs::file_magic::macho_universal_binary:
|
case sys::fs::file_magic::macho_universal_binary:
|
||||||
|
delete Object;
|
||||||
return 0;
|
return 0;
|
||||||
case sys::fs::file_magic::elf_relocatable:
|
case sys::fs::file_magic::elf_relocatable:
|
||||||
case sys::fs::file_magic::elf_executable:
|
case sys::fs::file_magic::elf_executable:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user