[macruby-changes] [5061] MacRuby/trunk/object.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Dec 21 07:35:43 PST 2010


Revision: 5061
          http://trac.macosforge.org/projects/ruby/changeset/5061
Author:   watson1978 at gmail.com
Date:     2010-12-21 07:35:37 -0800 (Tue, 21 Dec 2010)
Log Message:
-----------
Kernel#untrust with frozen object will throw an exception.

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

o = Object.new
assert_nothing_raised{ o.untrust }
o.trust
o.freeze
assert_raise(RuntimeError){ o.untrust }

puts :ok
}}}

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

Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c	2010-12-21 04:20:20 UTC (rev 5060)
+++ MacRuby/trunk/object.c	2010-12-21 15:35:37 UTC (rev 5061)
@@ -1013,37 +1013,37 @@
 rb_obj_untrust_imp(VALUE obj, SEL sel)
 {
     rb_secure(4);
-    if (!SPECIAL_CONST_P(obj) && NATIVE(obj)) {
-	switch (TYPE(obj)) {
-	    case T_SYMBOL:
-		break;
-
-	    case T_ARRAY:
-		if (rb_klass_is_rary(*(VALUE *)obj)) {
-		    RBASIC(obj)->flags |= FL_UNTRUSTED;
-		    break;
-		}
-		// fall through
-	    case T_STRING:
-		if (rb_klass_is_rstr(*(VALUE *)obj)) {
-		    RBASIC(obj)->flags |= FL_UNTRUSTED;
-		    break;
-		}
-		// fall through
-	    case T_HASH:
-		if (rb_klass_is_rhash(*(VALUE *)obj)) {
-		    RBASIC(obj)->flags |= FL_UNTRUSTED;
-		    break;
-		}
-	    default:
-		rb_objc_flag_set((const void *)obj, FL_UNTRUSTED, true);
-	}
-	return obj;
-    }
-    if (!OBJ_TAINTED(obj)) {
+    if (!OBJ_UNTRUSTED(obj)) {
 	if (OBJ_FROZEN(obj)) {
 	    rb_error_frozen("object");
 	}
+	if (!SPECIAL_CONST_P(obj) && NATIVE(obj)) {
+	    switch (TYPE(obj)) {
+		case T_SYMBOL:
+		    break;
+
+		case T_ARRAY:
+		    if (rb_klass_is_rary(*(VALUE *)obj)) {
+			RBASIC(obj)->flags |= FL_UNTRUSTED;
+			break;
+		    }
+		    // fall through
+		case T_STRING:
+		    if (rb_klass_is_rstr(*(VALUE *)obj)) {
+			RBASIC(obj)->flags |= FL_UNTRUSTED;
+			break;
+		    }
+		    // fall through
+		case T_HASH:
+		    if (rb_klass_is_rhash(*(VALUE *)obj)) {
+			RBASIC(obj)->flags |= FL_UNTRUSTED;
+			break;
+		    }
+		default:
+		    rb_objc_flag_set((const void *)obj, FL_UNTRUSTED, true);
+	    }
+	    return obj;
+	}
 	FL_SET(obj, FL_UNTRUSTED);
     }
     return obj;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101221/4adc7475/attachment.html>


More information about the macruby-changes mailing list