certik / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Clone() segfaults when passed an empty YAML::Node #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Not sure if this has been fixed in a version later than 0.51 (I saw another 
Clone issue in the log had been fixed), but Clone()ing an empty Node causes a 
segmentation fault.

Example:

YAML::Node foo;
YAML::Node bar;

bar = Clone(foo);  <---- Segmentation fault

This should either be a no-op or copy the empty node to bar. 

Reproducible on several installations.

Original issue reported on code.google.com by jack.sta...@gmail.com on 10 Dec 2013 at 4:57

GoogleCodeExporter commented 9 years ago
Workaround: Specify a NodeType in the empty Node ctor:

YAML::Node foo(YAML::NodeType::Sequence);
YAML::Node bar;

bar = Clone(foo);   <---- Works!

Original comment by jack.sta...@gmail.com on 10 Dec 2013 at 5:04

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by jbe...@gmail.com on 10 Dec 2013 at 6:59

GoogleCodeExporter commented 9 years ago
I'm not sure where this would have been fixed since 0.5.1, but it appears so:

{{{
Node node;
Node clone = Clone(node);
EXPECT_EQ(NodeType::Null, clone.Type());
}}}

passes at HEAD. 

Original comment by jbe...@gmail.com on 23 Mar 2014 at 4:32