diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-10-20 07:10:23 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-10-20 07:10:23 +0000 |
commit | 58ac90ff773d7fc5107d7f2a886dd475053115f9 (patch) | |
tree | 25f6e2a15a8e14b12ac653ac365d2fe34be0abd4 /marshal.c | |
parent | 125ca1a11a53810ac311012352f5b0773fc2bbde (diff) |
marshal load GC protect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r-- | marshal.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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); |