1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* struct.c (rb_struct_init_copy): disallow changing the size.

[ruby-dev:31168]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-07-12 08:03:18 +00:00
parent 6b6bf4dd48
commit 4c289d8d10
2 changed files with 8 additions and 8 deletions

View file

@ -1,3 +1,8 @@
Thu Jul 12 17:03:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* struct.c (rb_struct_init_copy): disallow changing the size.
[ruby-dev:31168]
Thu Jul 12 12:58:21 2007 Koichi Sasada <ko1@atdot.net>
* blockinlining.c: remove "yarv" prefix.

View file

@ -226,7 +226,7 @@ rb_struct_define(const char *name, ...)
ary = rb_ary_new();
va_start(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));
}
@ -515,13 +515,8 @@ rb_struct_init_copy(VALUE copy, VALUE s)
if (!rb_obj_is_instance_of(s, rb_obj_class(copy))) {
rb_raise(rb_eTypeError, "wrong argument class");
}
if (0 < RSTRUCT_LEN(s) && RSTRUCT_LEN(s) <= RSTRUCT_EMBED_LEN_MAX) {
RBASIC(copy)->flags &= ~RSTRUCT_EMBED_LEN_MASK;
RBASIC(copy)->flags |= RSTRUCT_LEN(s) << RSTRUCT_EMBED_LEN_SHIFT;
}
else {
RSTRUCT(copy)->as.heap.ptr = ALLOC_N(VALUE, RSTRUCT_LEN(s));
RSTRUCT(copy)->as.heap.len = RSTRUCT_LEN(s);
if (RSTRUCT_LEN(copy) != RSTRUCT_LEN(s)) {
rb_raise(rb_eTypeError, "struct size mismatch");
}
MEMCPY(RSTRUCT_PTR(copy), RSTRUCT_PTR(s), VALUE, RSTRUCT_LEN(copy));