From 481dca239365287462520a6c582756280bc742a3 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 21 May 2015 19:45:02 +0000 Subject: YAML: Null terminate block scalar's value. The commit null terminates the string value in the `yaml::BlockScalarNode` class. This change is motivated by the initial MIR serialization commit (r237708) that I reverted in r237730 because the LLVM IR source from the block scalar node wasn't terminated by a null character and thus the buildbots failed on one testcase sometimes. This change enables me to recommit the reverted commit. llvm-svn: 237942 --- llvm/lib/Support/YAMLParser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 41d446744fe..d55da5ef1e4 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -2379,7 +2379,8 @@ parse_property: , T.Range); case Token::TK_BlockScalar: { getNext(); - StringRef StrCopy = StringRef(T.Value).copy(NodeAllocator); + StringRef NullTerminatedStr(T.Value.c_str(), T.Value.length() + 1); + StringRef StrCopy = NullTerminatedStr.copy(NodeAllocator).drop_back(); return new (NodeAllocator) BlockScalarNode(stream.CurrentDoc, AnchorInfo.Range.substr(1), TagInfo.Range, StrCopy, T.Range); -- cgit v1.2.3