Skip to content

Commit

Permalink
* marshal.c (r_object0): struct allocation first to check if a
Browse files Browse the repository at this point in the history
  class is a struct.  compatibility check should come next.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Sep 9, 2007
1 parent 3ee33a6 commit c19fafb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Sep 10 01:21:23 2007 Yukihiro Matsumoto <matz@ruby-lang.org>

* marshal.c (r_object0): struct allocation first to check if a
class is a struct. compatibility check should come next.

Mon Sep 10 01:05:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>

* range.c (range_step): fixed integer overflow. [ruby-dev:31763]
Expand Down
10 changes: 5 additions & 5 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,18 +1254,18 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
ID slot;

klass = path2class(r_unique(arg));
mem = rb_struct_s_members(klass);
len = r_long(arg);

v = rb_obj_alloc(klass);
if (TYPE(v) != T_STRUCT) {
rb_raise(rb_eTypeError, "class %s not a struct", rb_class2name(klass));
}
mem = rb_struct_s_members(klass);
if (RARRAY_LEN(mem) != len) {
rb_raise(rb_eTypeError, "struct %s not compatible (struct size differs)",
rb_class2name(klass));
}

v = rb_obj_alloc(klass);
if (TYPE(v) != T_STRUCT) {
rb_raise(rb_eArgError, "dump format error");
}
v = r_entry(v, arg);
values = rb_ary_new2(len);
for (i=0; i<len; i++) {
Expand Down

0 comments on commit c19fafb

Please sign in to comment.