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

marshal load GC bug

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-10-20 09:20:08 +00:00
parent fd1fe9cf1d
commit 74dcd0fac7
2 changed files with 14 additions and 6 deletions

View file

@ -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,

View file

@ -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);