From: Pete Cooper Date: Thu, 24 Mar 2016 01:14:10 +0000 (+0000) Subject: Avoid UB deref of nullptr to reference. NFC. X-Git-Tag: llvmorg-3.9.0-rc1~11085 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07134ae364c4cba9158a2c43adb78a8da1051b3e;p=platform%2Fupstream%2Fllvm.git Avoid UB deref of nullptr to reference. NFC. Its possible for file to have no entry atom which means that there is no atom to check for being a thumb function. Instead just skip the thumb check and set the entry address to 0, which matches the current behaviour of getting a default initialised int from a map. llvm-svn: 264233 --- diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index b95745f..2d71c4c 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -715,6 +715,11 @@ void Util::updateSectionInfo(NormalizedFile &file) { } void Util::copyEntryPointAddress(NormalizedFile &nFile) { + if (!_entryAtom) { + nFile.entryAddress = 0; + return; + } + if (_ctx.outputTypeHasEntry()) { if (_archHandler.isThumbFunction(*_entryAtom)) nFile.entryAddress = (_atomToAddress[_entryAtom] | 1);