mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Fix reading empty token stack with a node with properties but no scalar.
E.g. `!2`.
This commit is contained in:
@@ -79,6 +79,12 @@ void SingleDocParser::HandleNode(EventHandler& eventHandler) {
|
|||||||
if (!anchor_name.empty())
|
if (!anchor_name.empty())
|
||||||
eventHandler.OnAnchor(mark, anchor_name);
|
eventHandler.OnAnchor(mark, anchor_name);
|
||||||
|
|
||||||
|
// after parsing properties, an empty node is again a possibility
|
||||||
|
if (m_scanner.empty()) {
|
||||||
|
eventHandler.OnNull(mark, anchor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const Token& token = m_scanner.peek();
|
const Token& token = m_scanner.peek();
|
||||||
|
|
||||||
if (token.type == Token::PLAIN_SCALAR && IsNullString(token.value)) {
|
if (token.type == Token::PLAIN_SCALAR && IsNullString(token.value)) {
|
||||||
|
@@ -257,5 +257,10 @@ TEST(NodeTest, LoadTagWithParenthesis) {
|
|||||||
EXPECT_EQ(node.as<std::string>(), "foo");
|
EXPECT_EQ(node.as<std::string>(), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, LoadTagWithNullScalar) {
|
||||||
|
Node node = Load("!2");
|
||||||
|
EXPECT_TRUE(node.IsNull());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace YAML
|
} // namespace YAML
|
||||||
|
Reference in New Issue
Block a user