ruby-changes:18601
From: tenderlove <ko1@a...>
Date: Sat, 22 Jan 2011 10:14:00 +0900 (JST)
Subject: [ruby-changes:18601] Ruby:r30625 (trunk): * ext/psych/parser.c (parse): fix assertion error when reusing a
tenderlove 2011-01-22 10:13:52 +0900 (Sat, 22 Jan 2011) New Revision: 30625 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30625 Log: * ext/psych/parser.c (parse): fix assertion error when reusing a parser after an exception has been raised * test/psych/test_parser.rb: test for assertion error Modified files: trunk/ChangeLog trunk/ext/psych/parser.c trunk/test/psych/test_parser.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30624) +++ ChangeLog (revision 30625) @@ -1,3 +1,10 @@ +Sat Jan 22 10:12:30 2011 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c (parse): fix assertion error when reusing a + parser after an exception has been raised + + * test/psych/test_parser.rb: test for assertion error + Sat Jan 22 04:09:22 2011 Aaron Patterson <aaron@t...> * ext/psych/lib/psych/nodes/node.rb: Make Psych::Nodes::Node Index: ext/psych/parser.c =================================================================== --- ext/psych/parser.c (revision 30624) +++ ext/psych/parser.c (revision 30625) @@ -96,6 +96,9 @@ size_t line = parser->mark.line; size_t column = parser->mark.column; + yaml_parser_delete(parser); + yaml_parser_initialize(parser); + rb_raise(ePsychSyntaxError, "couldn't parse YAML at line %d column %d", (int)line, (int)column); } Index: test/psych/test_parser.rb =================================================================== --- test/psych/test_parser.rb (revision 30624) +++ test/psych/test_parser.rb (revision 30625) @@ -128,6 +128,16 @@ end end + def test_syntax_error_twice + assert_raises(Psych::SyntaxError) do + @parser.parse("---\n\"foo\"\n\"bar\"\n") + end + + assert_raises(Psych::SyntaxError) do + @parser.parse("---\n\"foo\"\n\"bar\"\n") + end + end + def test_mapping_end @parser.parse("---\n!!map { key: value }") assert_called :end_mapping -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/