summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-12 06:19:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-12 06:19:06 +0000
commit9391daf9543835f2a5dd850cee422310d8e79449 (patch)
tree127cdc91b84ebb3523ae0c368653c05acc8fe83d
parent35028627e581b0a77385e6d6f4fee799c4a6a2f2 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--io.c4
-rw-r--r--marshal.c4
-rw-r--r--parse.y20
-rw-r--r--version.h6
5 files changed, 24 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index c81a02d03e..c7a224b836 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Sep 12 15:19:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@iDaemons.org>
* lib/tempfile.rb (Tempfile::make_tmpname): Allow to specify a
diff --git a/io.c b/io.c
index b299689a38..fa63537ab5 100644
--- a/io.c
+++ b/io.c
@@ -3455,8 +3455,8 @@ rb_io_s_sysopen(int argc, VALUE *argv)
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);
}
diff --git a/marshal.c b/marshal.c
index 8d0f91c7f3..710068caa8 100644
--- a/marshal.c
+++ b/marshal.c
@@ -309,7 +309,7 @@ load_mantissa(double d, const char *buf, int len)
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 @@ w_float(double d, struct dump_arg *arg)
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;
diff --git a/parse.y b/parse.y
index 541c336f71..91d0bac21b 100644
--- a/parse.y
+++ b/parse.y
@@ -8553,21 +8553,17 @@ rb_id2str(ID id)
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;
}
diff --git a/version.h b/version.h
index dec1cec9bf..082ff63c44 100644
--- a/version.h
+++ b/version.h
@@ -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[];