kastnermario / yaml-cpp

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

failed assert with incomplete input #161

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
To reproduce the problem run this:
{
    std::istringstream iss("---{header: {id: 1");
    YAML::Parser parser(iss);
    YAML::Node doc;
    parser.GetNextDocument(doc);
}

I am expecting an exception here, but I get a failed assert.

I am using version 0.3.0 on Vista 32bit

I am parsing network messages, so sometimes I get incomplete messages. I am 
expecting the library to throw an exception. After that, I am going to call 
iss.tellg() to know how much text was parsed (any other way?)

Original issue reported on code.google.com by mace...@gmail.com on 9 Jun 2012 at 7:07

GoogleCodeExporter commented 8 years ago
Thanks!

This is fixed in r8a5f69a395e7 in the default repo and rea0ce05f11c5 in the 
old-api repo.

It should now throw an exception for missing the "}" to close the map (but I 
think this example may not do exactly what you expect - without a space between 
the "---" and the "{header...", it will view "---{header" as a single scalar!)

As for iss.tellg(), that should work. You can also look at the "mark" variable 
in the exception, which tries to get as close as possible to the actual problem.

Original comment by jbe...@gmail.com on 9 Jun 2012 at 7:49

GoogleCodeExporter commented 8 years ago
Thank you for the ultra-fast reply and fix. Yes I forgot a space, that was a 
newline in the real code.

Original comment by mace...@gmail.com on 9 Jun 2012 at 9:02

GoogleCodeExporter commented 8 years ago
By the way, the automatic link for the commit in the old-api repo doesn't work. 
Let's see if this does:

rea0ce05f11c5?repo=old-api

Original comment by jbe...@gmail.com on 9 Jun 2012 at 9:18

GoogleCodeExporter commented 8 years ago
Dang, OK, how about this:

http://code.google.com/p/yaml-cpp/source/detail?r=ea0ce05f11c5dfa9cc2a9da1aeb3b3
d0a7f8cdd3&repo=old-api

Original comment by jbe...@gmail.com on 9 Jun 2012 at 9:19

GoogleCodeExporter commented 8 years ago
Thanks for the link.

I got curious about the new api and I am trying it right now. However, I can't 
seem to parse multiple documents. I posted the issue on the tutorial page.

Original comment by mace...@gmail.com on 10 Jun 2012 at 9:17