[前][次][番号順一覧][スレッド一覧]

ruby-changes:15386

From: tenderlove <ko1@a...>
Date: Sat, 10 Apr 2010 01:10:11 +0900 (JST)
Subject: [ruby-changes:15386] Ruby:r27278 (trunk): * ext/psych/parser.c: parse raises a TypeError when nil is passed in.

tenderlove	2010-04-10 01:09:55 +0900 (Sat, 10 Apr 2010)

  New Revision: 27278

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27278

  Log:
    * ext/psych/parser.c: parse raises a TypeError when nil is passed in.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/parser.c
    trunk/test/psych/test_psych.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27277)
+++ ChangeLog	(revision 27278)
@@ -1,3 +1,7 @@
+Sat Apr 10 01:08:53 2010  Aaron Patterson <aaron@t...>
+
+	* ext/psych/parser.c: parse raises a TypeError when nil is passed in.
+
 Sat Apr 10 00:01:51 2010  Yusuke Endoh  <mame@t...>
 
 	* ext/pty/lib/expect.rb: preserve buffer read, instead of discard.
Index: ext/psych/parser.c
===================================================================
--- ext/psych/parser.c	(revision 27277)
+++ ext/psych/parser.c	(revision 27278)
@@ -57,6 +57,7 @@
     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),
Index: test/psych/test_psych.rb
===================================================================
--- test/psych/test_psych.rb	(revision 27277)
+++ test/psych/test_psych.rb	(revision 27278)
@@ -4,6 +4,12 @@
 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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]