aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:27:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:27:52 +0000
commit912300c8ef3ca1a78fc802e751dc9cda30cfb091 (patch)
treef3f7c9300fd9f90f0febb5750440b44418d6999e
parentae35b252b992fc0c6f23f5c9b746763f994fc39d (diff)
downloadruby-912300c8ef3ca1a78fc802e751dc9cda30cfb091.tar.gz
psych_emitter.c: check string
* ext/psych/psych_emitter.c (start_document): ensure string before encoding conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/psych/psych_emitter.c6
-rw-r--r--test/psych/test_emitter.rb1
3 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6dc79717c8..c5b7799bab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Dec 13 18:27:53 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/psych/psych_emitter.c (start_document): ensure string before
+ encoding conversion.
+
Sun Dec 13 18:26:31 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/tk/tkutil/tkutil.c (tk_hash_kv): check types of array
diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c
index 29df96a562..078ae2b680 100644
--- a/ext/psych/psych_emitter.c
+++ b/ext/psych/psych_emitter.c
@@ -189,13 +189,15 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
}
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++;
}
diff --git a/test/psych/test_emitter.rb b/test/psych/test_emitter.rb
index 1c96c12379..fe198bd1b1 100644
--- a/test/psych/test_emitter.rb
+++ b/test/psych/test_emitter.rb
@@ -53,6 +53,7 @@ module Psych
[[], 'foo', false],
[[], ['foo'], false],
[[], [nil,nil], false],
+ [[1,1], [[nil, "tag:TALOS"]], 0],
].each do |args|
assert_raises(TypeError) do
@emitter.start_document(*args)