summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 19:53:55 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 19:53:55 +0000
commit11c447648218503cc7e069153fe1d1db2b3dd986 (patch)
tree764d6ae55fc9e35f3b759c19e8122e4bb3a80d71
parent901e94812a74d327c0c0ddbd12aef4b020b42f0c (diff)
* struct.c (rb_struct_init_copy): disallow changing the size.
[ruby-dev:31168] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@12978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--struct.c7
-rw-r--r--version.h2
3 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f5a850a2a..7af1e6557e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 16 04:53:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * struct.c (rb_struct_init_copy): disallow changing the size.
+ [ruby-dev:31168]
+
Thu Aug 16 04:52:11 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* random.c: documentation fix. srand(0) initializes PRNG with '0',
diff --git a/struct.c b/struct.c
index 45797c80a0..0dd5aba0a0 100644
--- a/struct.c
+++ b/struct.c
@@ -252,7 +252,7 @@ rb_struct_define(name, va_alist)
ary = rb_ary_new();
va_init_list(ar, name);
- while (mem = va_arg(ar, char*)) {
+ while ((mem = va_arg(ar, char*)) != 0) {
ID slot = rb_intern(mem);
rb_ary_push(ary, ID2SYM(slot));
}
@@ -557,8 +557,9 @@ rb_struct_init_copy(copy, s)
if (!rb_obj_is_instance_of(s, rb_obj_class(copy))) {
rb_raise(rb_eTypeError, "wrong argument class");
}
- RSTRUCT(copy)->ptr = ALLOC_N(VALUE, RSTRUCT(s)->len);
- RSTRUCT(copy)->len = RSTRUCT(s)->len;
+ if (RSTRUCT(copy)->len != RSTRUCT(s)->len) {
+ rb_raise(rb_eTypeError, "struct size mismatch");
+ }
MEMCPY(RSTRUCT(copy)->ptr, RSTRUCT(s)->ptr, VALUE, RSTRUCT(copy)->len);
return copy;
diff --git a/version.h b/version.h
index f701d93e46..ccd6a3a917 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2007-08-16"
#define RUBY_VERSION_CODE 185
#define RUBY_RELEASE_CODE 20070816
-#define RUBY_PATCHLEVEL 67
+#define RUBY_PATCHLEVEL 68
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8