MC/MachO: Fix possible null pointer dereference.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 9 Aug 2010 15:28:05 +0000 (15:28 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 9 Aug 2010 15:28:05 +0000 (15:28 +0000)
Discovered by Microsoft Visual Studio 2010 Code Analysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110575 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MachObjectWriter.cpp

index 7ca09511bdebd2515c3db3a83ce80d0af6c04ec1..d67dbc01e61cf2d4295c10ce81b40b02d3667152 100644 (file)
@@ -835,7 +835,7 @@ public:
       // FIXME: Currently, these are never generated (see code below). I cannot
       // find a case where they are actually emitted.
       Type = RIT_Vanilla;
-    } else {
+    } else if (SD) {
       // Check whether we need an external or internal relocation.
       if (doesSymbolRequireExternRelocation(SD)) {
         IsExtern = 1;