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

ruby-changes:1939

From: ko1@a...
Date: 12 Sep 2007 15:19:31 +0900
Subject: [ruby-changes:1939] nobu - Ruby:r13430 (trunk): * io.c (rb_io_s_sysopen): should not use alloca for unknowen size

nobu	2007-09-12 15:19:06 +0900 (Wed, 12 Sep 2007)

  New Revision: 13430

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/marshal.c
    trunk/parse.y
    trunk/version.h

  Log:
    * io.c (rb_io_s_sysopen): should not use alloca for unknowen size
      input.  [ruby-dev:31775]
    
    * parse.y (rb_id2str): ditto.
    
    * marshal.c (w_float): use snprintf instead of sprintf.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=13430&r2=13429
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=13430&r2=13429
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13430&r2=13429
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=13430&r2=13429
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/marshal.c?r1=13430&r2=13429

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13429)
+++ ChangeLog	(revision 13430)
@@ -1,3 +1,12 @@
+Wed Sep 12 15:19:04 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (rb_io_s_sysopen): should not use alloca for unknowen size
+	  input.  [ruby-dev:31775]
+
+	* parse.y (rb_id2str): ditto.
+
+	* marshal.c (w_float): use snprintf instead of sprintf.
+
 Tue Sep 11 17:28:00 2007  Akinori MUSHA  <knu@i...>
 
 	* lib/tempfile.rb (Tempfile::make_tmpname): Allow to specify a
Index: io.c
===================================================================
--- io.c	(revision 13429)
+++ io.c	(revision 13430)
@@ -3455,8 +3455,8 @@
     if (NIL_P(perm)) fmode = 0666;
     else             fmode = NUM2INT(perm);
 
-    path = ALLOCA_N(char, strlen(RSTRING_PTR(fname))+1);
-    strcpy(path, RSTRING_PTR(fname));
+    RB_GC_GUARD(fname) = rb_str_new4(fname);
+    path = RSTRING_PTR(fname);
     fd = rb_sysopen(path, flags, fmode);
     return INT2NUM(fd);
 }
Index: parse.y
===================================================================
--- parse.y	(revision 13429)
+++ parse.y	(revision 13430)
@@ -8553,21 +8553,17 @@
 
     if (is_attrset_id(id)) {
 	ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL;
+	VALUE str;
 
-      again:
-	name = rb_id2name(id2);
-	if (name) {
-	    char *buf = ALLOCA_N(char, strlen(name)+2);
-
-	    strcpy(buf, name);
-	    strcat(buf, "=");
-	    rb_intern(buf);
-	    return rb_id2str(id);
-	}
-	if (is_local_id(id2)) {
+	while (!(str = rb_id2str(id2))) {
+	    if (!is_local_id(id2)) return 0;
 	    id2 = (id & ~ID_SCOPE_MASK) | ID_CONST;
-	    goto again;
 	}
+	str = rb_str_dup(str);
+	rb_str_cat(buf, "=", 1);
+	rb_intern_str(str);
+	if (st_lookup(global_symbols.id_str, id, &data))
+	    return (VALUE)data;
     }
     return 0;
 }
Index: version.h
===================================================================
--- version.h	(revision 13429)
+++ version.h	(revision 13430)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2007-09-10"
+#define RUBY_RELEASE_DATE "2007-09-12"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20070910
+#define RUBY_RELEASE_CODE 20070912
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2007
 #define RUBY_RELEASE_MONTH 9
-#define RUBY_RELEASE_DAY 10
+#define RUBY_RELEASE_DAY 12
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: marshal.c
===================================================================
--- marshal.c	(revision 13429)
+++ marshal.c	(revision 13430)
@@ -309,7 +309,7 @@
 static void
 w_float(double d, struct dump_arg *arg)
 {
-    char buf[100];
+    char buf[FLOAT_DIG + (DECIMAL_MANT + 7) / 8 + 10];
 
     if (isinf(d)) {
 	if (d < 0) strcpy(buf, "-inf");
@@ -326,7 +326,7 @@
 	int len;
 
 	/* xxx: should not use system's sprintf(3) */
-	sprintf(buf, "%.*g", FLOAT_DIG, d);
+	snprintf(buf, sizeof(buf), "%.*g", FLOAT_DIG, d);
 	len = strlen(buf);
 	w_bytes(buf, len + save_mantissa(d, buf + len), arg);
 	return;

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

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