Fixing stale pointer problem in ELFObjectFile

llvm-svn: 174665
This commit is contained in:
Andrew Kaylor 2013-02-07 21:30:54 +00:00
parent 9006156a04
commit 213f6727c0
1 changed files with 3 additions and 2 deletions

View File

@ -189,10 +189,11 @@ ObjectFileELF::CreateInstance (const lldb::ModuleSP &module_sp,
const uint8_t *magic = data_sp->GetBytes() + data_offset;
if (ELFHeader::MagicBytesMatch(magic))
{
// Update the data to contain the entire file
// Update the data to contain the entire file if it doesn't already
if (data_sp->GetByteSize() < length)
if (data_sp->GetByteSize() < length) {
data_sp = file->MemoryMapFileContents(file_offset, length);
magic = data_sp->GetBytes() + data_offset;
}
unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
if (address_size == 4 || address_size == 8)
{