[lld] r264233 - Avoid UB deref of nullptr to reference. NFC.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 18:14:10 PDT 2016


Author: pete
Date: Wed Mar 23 20:14:10 2016
New Revision: 264233

URL: http://llvm.org/viewvc/llvm-project?rev=264233&view=rev
Log:
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.

Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=264233&r1=264232&r2=264233&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Wed Mar 23 20:14:10 2016
@@ -715,6 +715,11 @@ void Util::updateSectionInfo(NormalizedF
 }
 
 void Util::copyEntryPointAddress(NormalizedFile &nFile) {
+  if (!_entryAtom) {
+    nFile.entryAddress = 0;
+    return;
+  }
+
   if (_ctx.outputTypeHasEntry()) {
     if (_archHandler.isThumbFunction(*_entryAtom))
       nFile.entryAddress = (_atomToAddress[_entryAtom] | 1);




More information about the llvm-commits mailing list