[前][次][番号順一覧][スレッド一覧]

ruby-changes:28056

From: akr <ko1@a...>
Date: Thu, 4 Apr 2013 22:26:50 +0900 (JST)
Subject: [ruby-changes:28056] akr:r40108 (trunk): * object.c (rb_mod_cvar_set): Reverted "avoid inadvertent

akr	2013-04-04 22:26:39 +0900 (Thu, 04 Apr 2013)

  New Revision: 40108

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40108

  Log:
    * object.c (rb_mod_cvar_set): Reverted "avoid inadvertent
      symbol creation" to avoid SEGV by
      Class.new.class_variable_set(1, 2).

  Modified files:
    trunk/ChangeLog
    trunk/object.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40107)
+++ ChangeLog	(revision 40108)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr  4 22:08:46 2013  Tanaka Akira  <akr@f...>
+
+	* object.c (rb_mod_cvar_set): Reverted "avoid inadvertent
+	  symbol creation" to avoid SEGV by
+	  Class.new.class_variable_set(1, 2).
+
 Thu Apr  4 20:07:19 2013  Tanaka Akira  <akr@f...>
 
 	* ext/pathname/pathname.c (path_write): New method.
Index: object.c
===================================================================
--- object.c	(revision 40107)
+++ object.c	(revision 40108)
@@ -2296,21 +2296,11 @@ rb_mod_cvar_get(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2296
 static VALUE
 rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
 {
-    ID id;
+    ID id = rb_to_id(iv);
 
-    if (SYMBOL_P(iv)) {
-	id = SYM2ID(iv);
-	if (!rb_is_class_id(id)) {
-	    rb_name_error(id, "`%"PRIsVALUE"' is not allowed as an class variable name",
-			  QUOTE_ID(id));
-	}
-    }
-    else if (!rb_is_class_id(iv)) {
-	rb_name_error_str(iv, "`%"PRIsVALUE"' is not allowed as a class variable name",
-			  QUOTE(iv));
-    }
-    else {
-	id = rb_to_id(iv);
+    if (!rb_is_class_id(id)) {
+	rb_name_error(id, "`%"PRIsVALUE"' is not allowed as a class variable name",
+		      QUOTE_ID(id));
     }
     rb_cvar_set(obj, id, val);
     return val;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]