From cc0313436160b735a3d41361cb5e3eeb10fcbdad Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 13 Dec 2015 09:27:52 +0000 Subject: 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 --- ext/psych/psych_emitter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/psych') 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++; } -- cgit v1.2.3