aboutsummaryrefslogtreecommitdiffstats
path: root/ext/psych
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:28:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 09:28:51 +0000
commit60ca258a824c1d4b6a2a40ab91d9e1286914ebf3 (patch)
treee48512c803a3747f08e744aa1a8d946711300d17 /ext/psych
parent912300c8ef3ca1a78fc802e751dc9cda30cfb091 (diff)
downloadruby-60ca258a824c1d4b6a2a40ab91d9e1286914ebf3.tar.gz
psych_emitter.c: check tags range
* ext/psych/psych_emitter.c (start_document): should not exceed tags array range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych')
-rw-r--r--ext/psych/psych_emitter.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c
index 078ae2b680..371c285183 100644
--- a/ext/psych/psych_emitter.c
+++ b/ext/psych/psych_emitter.c
@@ -167,16 +167,18 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
if(RTEST(tags)) {
long i = 0;
+ long len;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding * encoding = rb_utf8_encoding();
#endif
Check_Type(tags, T_ARRAY);
- head = xcalloc((size_t)RARRAY_LEN(tags), sizeof(yaml_tag_directive_t));
+ len = RARRAY_LEN(tags);
+ head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
tail = head;
- for(i = 0; i < RARRAY_LEN(tags); i++) {
+ for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
VALUE tuple = RARRAY_AREF(tags, i);
VALUE name;
VALUE value;