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

source_changes at macosforge.org source_changes at macosforge.org
Sun Mar 6 03:08:29 PST 2011


Revision: 5256
          http://trac.macosforge.org/projects/ruby/changeset/5256
Author:   watson1978 at gmail.com
Date:     2011-03-06 03:08:26 -0800 (Sun, 06 Mar 2011)
Log Message:
-----------
Array#rotate will not raise a SecurityError when $SAFE is 4.

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

ary = [ "a", "b", "c" ]
ret = nil
Thread.start {
  $SAFE=4
  ret = ["b", "c", "a"] == ary.rotate

  begin
    ary.rotate!
  rescue SecurityError => err
  else
    raise "error"
  end
}.join

assert_equal(true, ret)
assert_equal(["a", "b", "c"], ary)

puts :ok
}}}

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

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2011-03-06 08:34:38 UTC (rev 5255)
+++ MacRuby/trunk/array.c	2011-03-06 11:08:26 UTC (rev 5256)
@@ -1353,7 +1353,6 @@
 VALUE
 ary_rotate(VALUE ary, long cnt)
 {
-    rb_ary_modify(ary);
     if (cnt != 0) {
 	long len = RARY(ary)->len;
 	if (len > 0 && (cnt = rotate_count(cnt, len)) > 0) {
@@ -1399,6 +1398,7 @@
     if (!NIL_P(n)) {
 	cnt = NUM2LONG(n);
     }
+    rb_ary_modify(ary);
     ary_rotate(ary, cnt);
     return ary;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110306/ab5135ae/attachment.html>


More information about the macruby-changes mailing list