kastnermario / yaml-cpp

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

Infinite loop when parsing unclosed inline block #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Parsing "bad YAML: [" results in an infinite loop. I'm not exactly sure why
does it happen but I see that YAML::Scanner::VerifySimpleKey(), called from
YAML::Scanner::VerifyAllSimpleKeys() called from YAML::Scanner::EndStream()
never terminates and the key grows forever, e.g. I have

(gdb) p key
$4 = {
  pos = 10,
  line = 0,
  column = 6099472,
  flowLevel = 0,
  pMapStart = 0x7fff8c058450,
  pKey = 0x45691f
}

(notice the column value).

Original issue reported on code.google.com by vzeitlin@gmail.com on 24 Sep 2008 at 8:47

GoogleCodeExporter commented 8 years ago
The problem was that we had a potential key at a different flow level, so 
normally it 
should simply wait until the flow level is closed before trying to verify the 
simple 
key; but since we hit an EOF (or end document, etc.), we can't ever close that 
flow 
level.

So I made it just pop the simple key, and it should properly output tokens, but 
then 
throw if you try to construct a representation.

Original comment by jbe...@gmail.com on 24 Sep 2008 at 10:48