summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-22 01:13:52 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-22 01:13:52 +0000
commit0331314d278d0590ff26eb7ec156f859b590464f (patch)
tree47060a334fc4212a01f49a960af4497f499a4137
parent960720ef4fd9662d94bbc25d5a6cfcaa313450a3 (diff)
* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/psych/parser.c3
-rw-r--r--test/psych/test_parser.rb10
3 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c4af4e5102..3f5dd01a7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Jan 22 10:12:30 2011 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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@tenderlovemaking.com>
* ext/psych/lib/psych/nodes/node.rb: Make Psych::Nodes::Node
diff --git a/ext/psych/parser.c b/ext/psych/parser.c
index 071b8c0720..5a9d2c75f9 100644
--- a/ext/psych/parser.c
+++ b/ext/psych/parser.c
@@ -96,6 +96,9 @@ static VALUE parse(VALUE self, VALUE yaml)
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);
}
diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb
index cd22914d3b..ca69b1a1e3 100644
--- a/test/psych/test_parser.rb
+++ b/test/psych/test_parser.rb
@@ -128,6 +128,16 @@ module Psych
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