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

source_changes at macosforge.org source_changes at macosforge.org
Sat Jan 1 20:05:21 PST 2011


Revision: 5095
          http://trac.macosforge.org/projects/ruby/changeset/5095
Author:   watson1978 at gmail.com
Date:     2011-01-01 20:05:17 -0800 (Sat, 01 Jan 2011)
Log Message:
-----------
Array#* will throw an exception when was passed very large times.

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

LONGP =  [127, 63, 31, 15, 7].map {|x| 2**x-1 }.find do |x|
  begin
    [].first(x)
  rescue ArgumentError
    true
  rescue RangeError
    false
  end
end

a = [ "a" ]
assert_raise(ArgumentError){ a * LONGP }

puts :ok
}}}

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

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2011-01-02 04:05:12 UTC (rev 5094)
+++ MacRuby/trunk/array.c	2011-01-02 04:05:17 UTC (rev 5095)
@@ -2352,7 +2352,7 @@
     VALUE ary2 = rary_alloc(rb_obj_class(ary), 0);
     if (len > 0) {
 	const long n = RARY(ary)->len;
-	if (LONG_MAX/len < n) {
+	if (ARY_MAX_SIZE/len < n) {
 	    rb_raise(rb_eArgError, "argument too big");
 	}
 	for (long i = 0; i < len; i++) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110101/f06c479f/attachment.html>


More information about the macruby-changes mailing list