marshal load GC protect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
125ca1a11a
commit
58ac90ff77
@ -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.
|
||||||
|
|
||||||
Mon Oct 18 16:15:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Mon Oct 18 16:15:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* ext/nkf/nkf.c (rb_nkf_kconv): output should be NUL terminated.
|
* ext/nkf/nkf.c (rb_nkf_kconv): output should be NUL terminated.
|
||||||
@ -6,6 +11,10 @@ Sun Oct 17 03:35:33 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
|
|||||||
|
|
||||||
* array.c (rb_ary_pop): forgot some freeze checks.
|
* array.c (rb_ary_pop): forgot some freeze checks.
|
||||||
|
|
||||||
|
Sat Oct 16 12:57:53 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
|
||||||
|
|
||||||
|
* array.c (rb_ary_sort): always returns the copied array.
|
||||||
|
|
||||||
Fri Oct 15 22:50:41 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
|
Fri Oct 15 22:50:41 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||||
|
|
||||||
* error.c (sys_nerr): on CYGWIN, it is _sys_nerr.
|
* error.c (sys_nerr): on CYGWIN, it is _sys_nerr.
|
||||||
|
25
array.c
25
array.c
@ -930,8 +930,8 @@ rb_ary_sort(ary)
|
|||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
ary = rb_ary_dup(ary);
|
ary = rb_ary_dup(ary);
|
||||||
if (RARRAY(ary)->len == 0) return ary;
|
rb_ary_sort_bang(ary);
|
||||||
return rb_ary_sort_bang(ary);
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -1365,10 +1365,9 @@ static VALUE
|
|||||||
rb_ary_uniq(ary)
|
rb_ary_uniq(ary)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
VALUE v = rb_ary_uniq_bang(rb_ary_dup(ary));
|
ary = rb_ary_dup(ary);
|
||||||
|
rb_ary_uniq_bang(ary);
|
||||||
if (NIL_P(v)) return ary;
|
return ary;
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1397,10 +1396,9 @@ static VALUE
|
|||||||
rb_ary_compact(ary)
|
rb_ary_compact(ary)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
VALUE v = rb_ary_compact_bang(rb_ary_dup(ary));
|
ary = rb_ary_dup(ary);
|
||||||
|
rb_ary_compact_bang(ary);
|
||||||
if (NIL_P(v)) return ary;
|
return ary;
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1442,10 +1440,9 @@ static VALUE
|
|||||||
rb_ary_flatten(ary)
|
rb_ary_flatten(ary)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
VALUE v = rb_ary_flatten_bang(rb_ary_dup(ary));
|
ary = rb_ary_dup(ary);
|
||||||
|
rb_ary_flatten_bang(ary);
|
||||||
if (NIL_P(v)) return ary;
|
return ary;
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -49,6 +49,7 @@ rb_nkf_kconv(obj, opt, src)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *opt_ptr, *opt_end;
|
char *opt_ptr, *opt_end;
|
||||||
|
volatile VALUE v;
|
||||||
|
|
||||||
reinit();
|
reinit();
|
||||||
opt_ptr = str2cstr(opt, &i);
|
opt_ptr = str2cstr(opt, &i);
|
||||||
@ -64,7 +65,8 @@ rb_nkf_kconv(obj, opt, src)
|
|||||||
|
|
||||||
input_ctr = 0;
|
input_ctr = 0;
|
||||||
input = str2cstr(src, &i_len);
|
input = str2cstr(src, &i_len);
|
||||||
dst = rb_str_new(0, i_len*3 + 10); /* large enough? */
|
dst = rb_str_new(0, i_len*3 + 10);
|
||||||
|
v = dst;
|
||||||
|
|
||||||
output_ctr = 0;
|
output_ctr = 0;
|
||||||
output = RSTRING(dst)->ptr;
|
output = RSTRING(dst)->ptr;
|
||||||
|
@ -148,7 +148,6 @@ EOF
|
|||||||
$CFLAGS="-DHAVE_SA_LEN "+$CFLAGS
|
$CFLAGS="-DHAVE_SA_LEN "+$CFLAGS
|
||||||
end
|
end
|
||||||
|
|
||||||
have_header("sys/sysctl.h")
|
|
||||||
have_header("netinet/tcp.h")
|
have_header("netinet/tcp.h")
|
||||||
have_header("netinet/udp.h")
|
have_header("netinet/udp.h")
|
||||||
|
|
||||||
|
@ -41,11 +41,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifndef NT
|
#ifndef NT
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYSCTL_H
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#endif
|
|
||||||
#ifndef NT
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
#ifndef NT
|
#ifndef NT
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#ifdef NETINET_TCP
|
#ifdef HAVE_NETINET_TCP_H
|
||||||
# include <netinet/tcp.h>
|
# include <netinet/tcp.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef NETINET_UDP
|
#ifdef HAVE_NETINET_UDP_H
|
||||||
# include <netinet/udp.h>
|
# include <netinet/udp.h>
|
||||||
#endif
|
#endif
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
15
marshal.c
15
marshal.c
@ -449,7 +449,7 @@ struct load_arg {
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *ptr, *end;
|
char *ptr, *end;
|
||||||
st_table *symbol;
|
st_table *symbol;
|
||||||
st_table *data;
|
VALUE data;
|
||||||
VALUE proc;
|
VALUE proc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -602,7 +602,7 @@ r_regist(v, arg)
|
|||||||
if (arg->proc) {
|
if (arg->proc) {
|
||||||
rb_funcall(arg->proc, rb_intern("call"), 1, v);
|
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;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,14 +612,16 @@ r_object(arg)
|
|||||||
{
|
{
|
||||||
VALUE v;
|
VALUE v;
|
||||||
int type = r_byte(arg);
|
int type = r_byte(arg);
|
||||||
|
long id;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TYPE_LINK:
|
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;
|
return v;
|
||||||
}
|
}
|
||||||
rb_raise(rb_eArgError, "dump format error (unlinked)");
|
rb_raise(rb_eArgError, "dump format error (unlinked)");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_UCLASS:
|
case TYPE_UCLASS:
|
||||||
{
|
{
|
||||||
@ -811,7 +813,6 @@ load_ensure(arg)
|
|||||||
struct load_arg *arg;
|
struct load_arg *arg;
|
||||||
{
|
{
|
||||||
st_free_table(arg->symbol);
|
st_free_table(arg->symbol);
|
||||||
st_free_table(arg->data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,11 +847,13 @@ marshal_load(argc, argv)
|
|||||||
|
|
||||||
major = r_byte(&arg);
|
major = r_byte(&arg);
|
||||||
if (major == MARSHAL_MAJOR) {
|
if (major == MARSHAL_MAJOR) {
|
||||||
|
volatile VALUE hash; /* protect from GC */
|
||||||
|
|
||||||
if (r_byte(&arg) != MARSHAL_MINOR) {
|
if (r_byte(&arg) != MARSHAL_MINOR) {
|
||||||
rb_warn("Old marshal file format (can be read)");
|
rb_warn("Old marshal file format (can be read)");
|
||||||
}
|
}
|
||||||
arg.symbol = st_init_numtable();
|
arg.symbol = st_init_numtable();
|
||||||
arg.data = st_init_numtable();
|
arg.data = hash = rb_hash_new();
|
||||||
if (NIL_P(proc)) arg.proc = 0;
|
if (NIL_P(proc)) arg.proc = 0;
|
||||||
else arg.proc = proc;
|
else arg.proc = proc;
|
||||||
v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
|
v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
|
||||||
|
136
string.c
136
string.c
@ -1042,10 +1042,9 @@ rb_str_sub(argc, argv, str)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_sub_bang(argc, argv, str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_sub_bang(argc, argv, str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1149,10 +1148,9 @@ rb_str_gsub(argc, argv, str)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_gsub_bang(argc, argv, str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_gsub_bang(argc, argv, str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1194,13 +1192,13 @@ rb_f_sub(argc, argv)
|
|||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
VALUE line, v;
|
VALUE line;
|
||||||
|
|
||||||
line = uscore_get();
|
line = rb_str_dup(uscore_get());
|
||||||
v = rb_str_sub_bang(argc, argv, line = rb_str_dup(line));
|
if (!NIL_P(rb_str_sub_bang(argc, argv, line))) {
|
||||||
if (NIL_P(v)) return line;
|
rb_lastline_set(line);
|
||||||
rb_lastline_set(v);
|
}
|
||||||
return v;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1216,13 +1214,13 @@ rb_f_gsub(argc, argv)
|
|||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
VALUE line, v;
|
VALUE line;
|
||||||
|
|
||||||
line = uscore_get();
|
line = rb_str_dup(uscore_get());
|
||||||
v = rb_str_gsub_bang(argc, argv, line = rb_str_dup(line));
|
if (!NIL_P(rb_str_gsub_bang(argc, argv, line = rb_str_dup(line)))) {
|
||||||
if (NIL_P(v)) return line;
|
rb_lastline_set(line);
|
||||||
rb_lastline_set(v);
|
}
|
||||||
return v;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1523,10 +1521,9 @@ static VALUE
|
|||||||
rb_str_upcase(str)
|
rb_str_upcase(str)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_upcase_bang(str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_upcase_bang(str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1557,10 +1554,9 @@ static VALUE
|
|||||||
rb_str_downcase(str)
|
rb_str_downcase(str)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_downcase_bang(str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_downcase_bang(str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1593,10 +1589,9 @@ static VALUE
|
|||||||
rb_str_capitalize(str)
|
rb_str_capitalize(str)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_capitalize_bang(str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_capitalize_bang(str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1631,10 +1626,9 @@ static VALUE
|
|||||||
rb_str_swapcase(str)
|
rb_str_swapcase(str)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_swapcase_bang(str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_swapcase_bang(str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef unsigned char *USTR;
|
typedef unsigned char *USTR;
|
||||||
@ -1782,10 +1776,9 @@ static VALUE
|
|||||||
rb_str_tr(str, src, repl)
|
rb_str_tr(str, src, repl)
|
||||||
VALUE str, src, repl;
|
VALUE str, src, repl;
|
||||||
{
|
{
|
||||||
VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 0);
|
str = rb_str_dup(str);
|
||||||
|
tr_trans(str, src, repl, 0);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1866,10 +1859,9 @@ rb_str_delete(argc, argv, str)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_delete_bang(argc, argv, str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_delete_bang(argc, argv, str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1927,10 +1919,9 @@ rb_str_squeeze(argc, argv, str)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_squeeze_bang(argc, argv, str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_squeeze_bang(argc, argv, str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1944,10 +1935,9 @@ static VALUE
|
|||||||
rb_str_tr_s(str, src, repl)
|
rb_str_tr_s(str, src, repl)
|
||||||
VALUE str, src, repl;
|
VALUE str, src, repl;
|
||||||
{
|
{
|
||||||
VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 1);
|
str = rb_str_dup(str);
|
||||||
|
tr_trans(str, src, repl, 1);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2235,10 +2225,9 @@ static VALUE
|
|||||||
rb_str_chop(str)
|
rb_str_chop(str)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_chop_bang(str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_chop_bang(str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2251,12 +2240,12 @@ rb_f_chop_bang(str)
|
|||||||
static VALUE
|
static VALUE
|
||||||
rb_f_chop()
|
rb_f_chop()
|
||||||
{
|
{
|
||||||
VALUE str = uscore_get();
|
VALUE str = rb_str_dup(uscore_get());
|
||||||
VALUE val = rb_str_chop_bang(str = rb_str_dup(str));
|
|
||||||
|
|
||||||
if (NIL_P(val)) return str;
|
if (!NIL_P(rb_str_chop_bang(str))) {
|
||||||
rb_lastline_set(val);
|
rb_lastline_set(str);
|
||||||
return val;
|
}
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2308,10 +2297,9 @@ rb_str_chomp(argc, argv, str)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_chomp_bang(argc, argv, str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_chomp_bang(argc, argv, str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2327,12 +2315,11 @@ rb_f_chomp(argc, argv)
|
|||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
VALUE str = uscore_get();
|
VALUE str = rb_str_dup(uscore_get());
|
||||||
VALUE val = rb_str_chomp_bang(argc, argv, str = rb_str_dup(str));
|
if (!NIL_P(rb_str_chomp_bang(argc, argv, str))) {
|
||||||
|
rb_lastline_set(str);
|
||||||
if (NIL_P(val)) return str;
|
}
|
||||||
rb_lastline_set(val);
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2375,10 +2362,9 @@ static VALUE
|
|||||||
rb_str_strip(str)
|
rb_str_strip(str)
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE val = rb_str_strip_bang(str = rb_str_dup(str));
|
str = rb_str_dup(str);
|
||||||
|
rb_str_strip_bang(str);
|
||||||
if (NIL_P(val)) return str;
|
return str;
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user