id	summary	reporter	owner	description	type	status	priority	component	severity	resolution	keywords	cc
156	libyaml fails to identify simple keys in very long files on 32-bit platforms	ppelletier@…	xi	"I have file which contains thousands of relatively short YAML documents, so the file is large (nearly a gigabyte) but the individual documents are not.

I can provide this file if necessary, but I'm not attaching it because it's so large (982M uncompressed, and still 45M when bzip2'ed).

I was getting this error:

{{{
Parser error: while parsing a block mapping at line 9259457, column 5
did not find expected key at line 9260367, column 5
}}}

This error occurs in both libyaml-0.1.2 and libyaml-0.1.3, but only on 32-bit machines (I tried Ubuntu 8.04 for x86-32, and Intel Mac OS X 10.5 with the compiler in 32-bit mode).  If I parse the same file with libyaml on a 64-bit machine (e. g. Ubuntu 8.04 for x86-64), it parses successfully with no error.

I eventually tracked this problem down to an overflow in pointer arithmetic in yaml_parser_save_simple_key(), in yaml-0.1.3/src/scanner.c on line 1125.  I changed this:

{{{
        simple_key.token_number = 
            parser->tokens_parsed + parser->tokens.tail - parser->tokens.head;
}}}

to this:

{{{
        simple_key.token_number = 
            parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
}}}

which caused my file to be parsed successfully, even on 32-bit platforms.  So, I would recommend adding this fix to libyaml-0.1.4.  Thanks!
"	defect	closed	normal	libyaml	normal	fixed		
