"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "f529626c6c518fb0fbdb0a4cdbdea4fa07f20866"
Commit 812a2dc6 authored by Jesse Beder's avatar Jesse Beder
Browse files

Fixed assignment with an empty node (new API) - a segfault that only showed up in debuggable

parent add46094
...@@ -100,7 +100,9 @@ namespace YAML ...@@ -100,7 +100,9 @@ namespace YAML
// assignment // assignment
inline bool Node::is(const Node& rhs) const inline bool Node::is(const Node& rhs) const
{ {
return m_pNode ? m_pNode->is(*rhs.m_pNode) : false; if(!m_pNode || !rhs.m_pNode)
return false;
return m_pNode->is(*rhs.m_pNode);
} }
template<typename T> template<typename T>
......
...@@ -279,6 +279,13 @@ namespace Test ...@@ -279,6 +279,13 @@ namespace Test
YAML_ASSERT(!!node["foo"]); YAML_ASSERT(!!node["foo"]);
return true; return true;
} }
TEST Reassign()
{
YAML::Node node = YAML::Load("foo");
node = YAML::Node();
return true;
}
} }
void RunNodeTest(TEST (*test)(), const std::string& name, int& passed, int& total) { void RunNodeTest(TEST (*test)(), const std::string& name, int& passed, int& total) {
...@@ -324,6 +331,7 @@ namespace Test ...@@ -324,6 +331,7 @@ namespace Test
RunNodeTest(&Node::TempMapVariableAlias, "temp map variable alias", passed, total); RunNodeTest(&Node::TempMapVariableAlias, "temp map variable alias", passed, total);
RunNodeTest(&Node::Bool, "bool", passed, total); RunNodeTest(&Node::Bool, "bool", passed, total);
RunNodeTest(&Node::AutoBoolConversion, "auto bool conversion", passed, total); RunNodeTest(&Node::AutoBoolConversion, "auto bool conversion", passed, total);
RunNodeTest(&Node::Reassign, "reassign", passed, total);
std::cout << "Node tests: " << passed << "/" << total << " passed\n"; std::cout << "Node tests: " << passed << "/" << total << " passed\n";
return passed == total; return passed == total;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment