summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/psych/parser.c1
-rw-r--r--test/psych/test_psych.rb6
3 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a227b8404f..44b80d7f22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Apr 10 01:08:53 2010 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/parser.c: parse raises a TypeError when nil is passed in.
+
Sat Apr 10 00:01:51 2010 Yusuke Endoh <mame@tsg.ne.jp>
* ext/pty/lib/expect.rb: preserve buffer read, instead of discard.
diff --git a/ext/psych/parser.c b/ext/psych/parser.c
index dd64c25101..5f5b2537c6 100644
--- a/ext/psych/parser.c
+++ b/ext/psych/parser.c
@@ -57,6 +57,7 @@ static VALUE parse(VALUE self, VALUE yaml)
if(rb_respond_to(yaml, id_read)) {
yaml_parser_set_input(&parser, io_reader, (void *)yaml);
} else {
+ Check_Type(yaml, T_STRING);
yaml_parser_set_input_string(
&parser,
(const unsigned char *)StringValuePtr(yaml),
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 22baa1489e..91c67b1664 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -4,6 +4,12 @@ require 'stringio'
require 'tempfile'
class TestPsych < Psych::TestCase
+ def test_load_argument_error
+ assert_raises(TypeError) do
+ Psych.load nil
+ end
+ end
+
def test_dump_stream
things = [22, "foo \n", {}]
stream = Psych.dump_stream(*things)