================
@@ -265,22 +265,21 @@ Expected<StringRef> 
YAMLRemarkParser::parseKey(yaml::KeyValueNode &Node) {
 }
 
 Expected<StringRef> YAMLRemarkParser::parseStr(yaml::KeyValueNode &Node) {
-  auto *Value = dyn_cast_if_present<yaml::ScalarNode>(Node.getValue());
-  yaml::BlockScalarNode *ValueBlock;
-  StringRef Result;
-  if (!Value) {
-    // Try to parse the value as a block node.
-    ValueBlock = dyn_cast_if_present<yaml::BlockScalarNode>(Node.getValue());
-    if (!ValueBlock)
-      return error("expected a value of scalar type.", Node);
-    Result = ValueBlock->getValue();
-  } else
-    Result = Value->getRawValue();
-
-  Result.consume_front("\'");
-  Result.consume_back("\'");
-
-  return Result;
+  yaml::Node *Value = Node.getValue();
+  // A block value lives in the YAML document, which next() frees before
+  // returning the remark.
+  if (auto *Block = dyn_cast_if_present<yaml::BlockScalarNode>(Value))
+    return Block->getValue().copy(Alloc);
+
+  auto *Scalar = dyn_cast_if_present<yaml::ScalarNode>(Value);
+  if (!Scalar)
+    return error("expected a value of scalar type.", Node);
+  SmallString<32> Storage;
+  StringRef Result = Scalar->getValue(Storage);
----------------
xlauko wrote:

Worse than a cut-off. The bitstream string table splits on NUL, so every later 
string gets the wrong index.
I changed YAML parser to reject NUL, and added a test for it.

https://github.com/llvm/llvm-project/pull/227654
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to