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

ruby-changes:40999

From: nobu <ko1@a...>
Date: Sun, 13 Dec 2015 18:28:00 +0900 (JST)
Subject: [ruby-changes:40999] nobu:r53078 (trunk): psych_emitter.c: check string

nobu	2015-12-13 18:27:52 +0900 (Sun, 13 Dec 2015)

  New Revision: 53078

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

  Log:
    psych_emitter.c: check string
    
    * ext/psych/psych_emitter.c (start_document): ensure string before
      encoding conversion.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/psych_emitter.c
    trunk/test/psych/test_emitter.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53077)
+++ ChangeLog	(revision 53078)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec 13 18:27:53 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/psych/psych_emitter.c (start_document): ensure string before
+	  encoding conversion.
+
 Sun Dec 13 18:26:31 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/tk/tkutil/tkutil.c (tk_hash_kv): check types of array
Index: ext/psych/psych_emitter.c
===================================================================
--- ext/psych/psych_emitter.c	(revision 53077)
+++ ext/psych/psych_emitter.c	(revision 53078)
@@ -189,13 +189,15 @@ static VALUE start_document(VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L189
 	    }
 	    name  = RARRAY_AREF(tuple, 0);
 	    value = RARRAY_AREF(tuple, 1);
+	    StringValue(name);
+	    StringValue(value);
 #ifdef HAVE_RUBY_ENCODING_H
 	    name = rb_str_export_to_enc(name, encoding);
 	    value = rb_str_export_to_enc(value, encoding);
 #endif
 
-	    tail->handle = (yaml_char_t *)StringValuePtr(name);
-	    tail->prefix = (yaml_char_t *)StringValuePtr(value);
+	    tail->handle = (yaml_char_t *)RSTRING_PTR(name);
+	    tail->prefix = (yaml_char_t *)RSTRING_PTR(value);
 
 	    tail++;
 	}
Index: test/psych/test_emitter.rb
===================================================================
--- test/psych/test_emitter.rb	(revision 53077)
+++ test/psych/test_emitter.rb	(revision 53078)
@@ -53,6 +53,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_emitter.rb#L53
         [[], 'foo', false],
         [[], ['foo'], false],
         [[], [nil,nil], false],
+        [[1,1], [[nil, "tag:TALOS"]], 0],
       ].each do |args|
         assert_raises(TypeError) do
           @emitter.start_document(*args)

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

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