[llvm] r204429 - MCParser: add an assertion

Saleem Abdulrasool compnerd at compnerd.org
Thu Mar 20 22:13:23 PDT 2014


Author: compnerd
Date: Fri Mar 21 00:13:23 2014
New Revision: 204429

URL: http://llvm.org/viewvc/llvm-project?rev=204429&view=rev
Log:
MCParser: add an assertion

Add an assertion that the section is not NULL.  Potential NULL pointer
dereference identified by clang static analyzer.

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=204429&r1=204428&r2=204429&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Mar 21 00:13:23 2014
@@ -2694,7 +2694,9 @@ bool AsmParser::parseDirectiveAlign(bool
 
   // 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);





More information about the llvm-commits mailing list