MCParser: add an assertion
authorSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 21 Mar 2014 05:13:23 +0000 (05:13 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 21 Mar 2014 05:13:23 +0000 (05:13 +0000)
Add an assertion that the section is not NULL.  Potential NULL pointer
dereference identified by clang static analyzer.

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

lib/MC/MCParser/AsmParser.cpp

index 665e3d33d88d167203402914c5435bec2f4a04b4..ca603cf613068807a24bba3300a627eaab9bef8b 100644 (file)
@@ -2694,7 +2694,9 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
 
   // Check whether we should use optimal code alignment for this .align
   // directive.
-  bool UseCodeAlign = getStreamer().getCurrentSection().first->UseCodeAlign();
+  const MCSection *Section = getStreamer().getCurrentSection().first;
+  assert(Section && "must have section to emit alignment");
+  bool UseCodeAlign = Section->UseCodeAlign();
   if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) &&
       ValueSize == 1 && UseCodeAlign) {
     getStreamer().EmitCodeAlignment(Alignment, MaxBytesToFill);