From: Pete Cooper Date: Fri, 29 May 2015 17:19:11 +0000 (+0000) Subject: Fix crash in MCExpr::print. X-Git-Tag: android-x86-7.1-r4~47574 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b2faffd63aa29617402aad745d8aabbd60f67a96;p=android-x86%2Fexternal-llvm.git Fix crash in MCExpr::print. Symbols are no longer required to be named, but this leads to a crash here if an unnamed symbol checks that its first character is '$'. Change the code to first check for a name, then check its first character. No test case i'm afraid as this is debugging code, but any test case with temp labels and 'llc --debug --filetype=obj' would have crashed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238579 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 1c0dc3f703a..1b328ac436f 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -43,7 +43,7 @@ void MCExpr::print(raw_ostream &OS) const { const MCSymbol &Sym = SRE.getSymbol(); // Parenthesize names that start with $ so that they don't look like // absolute names. - bool UseParens = Sym.getName()[0] == '$'; + bool UseParens = !Sym.getName().empty() && Sym.getName()[0] == '$'; if (UseParens) OS << '(' << Sym << ')'; else