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

ruby-changes:2003

From: ko1@a...
Date: 23 Sep 2007 08:58:15 +0900
Subject: [ruby-changes:2003] nobu - Ruby:r13494 (ruby_1_8, trunk): * eval_method.ci (rb_attr): should not use alloca for unknowen size

nobu	2007-09-23 08:58:03 +0900 (Sun, 23 Sep 2007)

  New Revision: 13494

  Modified files:
    branches/ruby_1_8/ChangeLog
    trunk/ChangeLog
    trunk/eval_method.ci
    trunk/parse.y

  Log:
    * eval_method.ci (rb_attr): should not use alloca for unknowen size
      input.  [ruby-dev:31816]
    
    * parse.y (rb_intern_str): prevent str from optimization.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=13494&r2=13493
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=13494&r2=13493
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13494&r2=13493
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_method.ci?r1=13494&r2=13493

Index: eval_method.ci
===================================================================
--- eval_method.ci	(revision 13493)
+++ eval_method.ci	(revision 13494)
@@ -409,10 +409,8 @@
 rb_attr(VALUE klass, ID id, int read, int write, int ex)
 {
     const char *name;
-    char *buf;
     ID attriv;
     int noex;
-    size_t len;
 
     if (!ex) {
 	noex = NOEX_PUBLIC;
@@ -439,10 +437,7 @@
     if (!name) {
 	rb_raise(rb_eArgError, "argument needs to be symbol or string");
     }
-    len = strlen(name) + 2;
-    buf = ALLOCA_N(char, len);
-    snprintf(buf, len, "@%s", name);
-    attriv = rb_intern(buf);
+    attriv = rb_intern_str(rb_sprintf("@%s", name));
     if (read) {
 	rb_add_method(klass, id, NEW_IVAR(attriv), noex);
     }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13493)
+++ ChangeLog	(revision 13494)
@@ -1,3 +1,10 @@
+Sun Sep 23 08:58:01 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval_method.ci (rb_attr): should not use alloca for unknowen size
+	  input.  [ruby-dev:31816]
+
+	* parse.y (rb_intern_str): prevent str from optimization.
+
 Sun Sep 23 06:16:04 2007  Nobuyoshi Nakada  <nobu@r...>
 
 	* eval_method.ci (remove_method): check for undefined method.
Index: parse.y
===================================================================
--- parse.y	(revision 13493)
+++ parse.y	(revision 13494)
@@ -8528,7 +8528,9 @@
 ID
 rb_intern_str(VALUE str)
 {
-    return rb_intern3(RSTRING_PTR(str), RSTRING_LEN(str), rb_enc_get(str));
+    ID id = rb_intern3(RSTRING_PTR(str), RSTRING_LEN(str), rb_enc_get(str));
+    RB_GC_GUARD(str);
+    return id;
 }
 
 VALUE
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 13493)
+++ ruby_1_8/ChangeLog	(revision 13494)
@@ -1,3 +1,10 @@
+Sun Sep 23 08:58:01 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval_method.ci (rb_attr): should not use alloca for unknowen size
+	  input.  [ruby-dev:31816]
+
+	* parse.y (rb_intern_str): prevent str from optimization.
+
 Sun Sep 23 05:42:35 2007  URABE Shyouhei  <shyouhei@r...>
 
 	* lib/rdoc/options.rb (Options::check_diagram): dot -V output

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

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