diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-10-20 09:20:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-10-20 09:20:08 +0000 |
commit | 74dcd0fac76be99fb984cb1366a2de2c27327da6 (patch) | |
tree | b68120f1d60a958bed5f10cc6bf7cc4694d06aa3 | |
parent | fd1fe9cf1d96e9b52478befa123836c73728e3e4 (diff) |
marshal load GC bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | marshal.c | 15 |
2 files changed, 14 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Wed Oct 20 15:14:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp> + + * marshal.c (marshal_load): should protect the generated object + table (arg->data) from GC. + Fri Oct 15 01:32:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp> * ext/Win32API/Win32API.c (Win32API_Call): need to use NUM2ULONG, @@ -449,7 +449,7 @@ struct load_arg { FILE *fp; char *ptr, *end; st_table *symbol; - st_table *data; + VALUE data; VALUE proc; }; @@ -602,7 +602,7 @@ r_regist(v, arg) if (arg->proc) { rb_funcall(arg->proc, rb_intern("call"), 1, v); } - st_insert(arg->data, arg->data->num_entries, v); + rb_hash_aset(arg->data, INT2FIX(RHASH(arg->data)->tbl->num_entries), v); return v; } @@ -612,14 +612,16 @@ r_object(arg) { VALUE v; int type = r_byte(arg); + long id; switch (type) { case TYPE_LINK: - if (st_lookup(arg->data, r_long(arg), &v)) { + id = r_long(arg); + if (v = rb_hash_aref(arg->data, INT2FIX(id))) { return v; } rb_raise(rb_eArgError, "dump format error (unlinked)"); - break; + break; case TYPE_UCLASS: { @@ -811,7 +813,6 @@ load_ensure(arg) struct load_arg *arg; { st_free_table(arg->symbol); - st_free_table(arg->data); return 0; } @@ -846,11 +847,13 @@ marshal_load(argc, argv) major = r_byte(&arg); if (major == MARSHAL_MAJOR) { + volatile VALUE hash; /* protect from GC */ + if (r_byte(&arg) != MARSHAL_MINOR) { rb_warn("Old marshal file format (can be read)"); } arg.symbol = st_init_numtable(); - arg.data = st_init_numtable(); + arg.data = hash = rb_hash_new(); if (NIL_P(proc)) arg.proc = 0; else arg.proc = proc; v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg); |