Don't call back() on an empty SmallVector. Found by -fsanitize=enum!
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 22 Dec 2012 00:15:13 +0000 (00:15 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 22 Dec 2012 00:15:13 +0000 (00:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170968 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/YAMLTraits.cpp

index a31c31915a170eda5e8112190a092c8fc94efe45..8fcef40d243f4499364034eb38632cf288b79b8b 100644 (file)
@@ -516,7 +516,7 @@ void Output::output(StringRef s) {
 
 void Output::outputUpToEndOfLine(StringRef s) {
   this->output(s);
-  if (StateStack.back() != inFlowSeq)
+  if (StateStack.empty() || StateStack.back() != inFlowSeq)
     NeedsNewLine = true;
 }