[macruby-changes] [5096] MacRuby/trunk/array.c

source_changes at macosforge.org source_changes at macosforge.org
Sat Jan 1 21:26:52 PST 2011


Revision: 5096
          http://trac.macosforge.org/projects/ruby/changeset/5096
Author:   watson1978 at gmail.com
Date:     2011-01-01 21:26:48 -0800 (Sat, 01 Jan 2011)
Log Message:
-----------
rary_splice will raise a exception when was specified with very huge range.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

n = 9223372036854775807
a = []
assert_raise(IndexError){ a[n .. -1] = 1 }

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/array.c

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2011-01-02 04:05:17 UTC (rev 5095)
+++ MacRuby/trunk/array.c	2011-01-02 05:26:48 UTC (rev 5096)
@@ -928,6 +928,9 @@
 	rpl = rb_ary_dup(rpl);
     }
     if (beg >= n) {
+	if (beg > ARY_MAX_SIZE - rlen) {
+	    rb_raise(rb_eIndexError, "index %ld too big", beg);
+	}
 	for (long i = n; i < beg; i++) {
 	    rary_push(ary, Qnil);
 	}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110101/fbd9c231/attachment.html>


More information about the macruby-changes mailing list