Skip to content

Commit

Permalink
* io.c (read_all): block string buffer modification during
Browse files Browse the repository at this point in the history
  rb_io_fread() by freezing it temporarily. [ruby-dev:24479]

* dir.c (rb_push_glob): block call at once the end of method.
  [ruby-dev:24487]

* ext/enumerator/enumerator.c (enum_each_slice): remove
  rb_gc_force_recycle() to prevent potential SEGV.
  [ruby-dev:24499]

* ext/zlib/zlib.c (zstream_expand_buffer): hide internal string
  buffer by clearing klass.  [ruby-dev:24510]

* ext/socket/socket.c (sock_s_getservbyaname): protocol string
  might be altered.  [ruby-dev:24503]

* string.c (rb_str_upto): check if return value from succ is a
  string.  [ruby-dev:24504]

* io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
  avoid mode string modification.  [ruby-dev:24454]

* io.c (rb_io_getline_fast): should take delim as unsigned char to
  distinguish EOF and '\377'.  [ruby-dev:24460]

* io.c (rb_io_getline): add check for RS modification.
  [ruby-dev:24461]

* enum.c (enum_sort_by): use qsort() directly instead using
  rb_iterate().  [ruby-dev:24462]

* enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
  prevent access to recycled object (via continuation for
  example).  [ruby-dev:24463]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Oct 19, 2004
1 parent c0700eb commit 1057902
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 124 deletions.
46 changes: 46 additions & 0 deletions ChangeLog
@@ -1,3 +1,18 @@
Tue Oct 19 17:24:11 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

* io.c (read_all): block string buffer modification during
rb_io_fread() by freezing it temporarily. [ruby-dev:24479]

* dir.c (rb_push_glob): block call at once the end of method.
[ruby-dev:24487]

* ext/enumerator/enumerator.c (enum_each_slice): remove
rb_gc_force_recycle() to prevent potential SEGV.
[ruby-dev:24499]

* ext/zlib/zlib.c (zstream_expand_buffer): hide internal string
buffer by clearing klass. [ruby-dev:24510]

Tue Oct 19 08:47:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>

* string.c (rb_str_upto): method result must be checked. [ruby-dev:24504]
Expand All @@ -24,6 +39,14 @@ Mon Oct 18 01:56:03 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httprequest.rb (WEBrick::HTTPRequest#initialize):
initial value of accpet-* should be array.

Mon Oct 18 00:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

* ext/socket/socket.c (sock_s_getservbyaname): protocol string
might be altered. [ruby-dev:24503]

* string.c (rb_str_upto): check if return value from succ is a
string. [ruby-dev:24504]

Sun Oct 17 23:03:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>

* ext/tk/lib/tk/timer.rb: TkTimer#start and restart accept a block
Expand Down Expand Up @@ -113,6 +136,24 @@ Tue Oct 12 15:05:32 2004 WATANABE Hirofumi <eban@ruby-lang.org>

* io.c (MODE_BINMODE, MODE_BINARY): fixed reversed condition.

Mon Oct 11 17:51:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

* io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
avoid mode string modification. [ruby-dev:24454]

* io.c (rb_io_getline_fast): should take delim as unsigned char to
distinguish EOF and '\377'. [ruby-dev:24460]

* io.c (rb_io_getline): add check for RS modification.
[ruby-dev:24461]

* enum.c (enum_sort_by): use qsort() directly instead using
rb_iterate(). [ruby-dev:24462]

* enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
prevent access to recycled object (via continuation for
example). [ruby-dev:24463]

Mon Oct 11 13:48:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>

* ext/tk/lib/tk/*: untabify
Expand Down Expand Up @@ -144,6 +185,11 @@ Sat Oct 9 19:50:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_getline): should not treat char as negative value.
[ruby-dev:24460]

Sat Oct 9 00:25:39 2004 Tanaka Akira <akr@m17n.org>

* io.c (rb_io_fread): rb_thread_wait_fd() was lost.
[ruby-dev:24457]

Fri Oct 8 21:36:56 2004 Minero Aoki <aamine@loveruby.net>

* lib/fileutils.rb (fu_traverse): return value of Dir.entries is
Expand Down
19 changes: 6 additions & 13 deletions dir.c
Expand Up @@ -1403,14 +1403,7 @@ push_pattern(path, ary)
const char *path;
VALUE ary;
{
VALUE str = rb_tainted_str_new2(path);

if (!NIL_P(ary)) {
rb_ary_push(ary, str);
}
else {
rb_yield(str);
}
rb_ary_push(ary, rb_tainted_str_new2(path));
}

static int
Expand Down Expand Up @@ -1478,13 +1471,9 @@ rb_push_glob(str, flags) /* '\0' is delimiter */
const char *p, *pend;
VALUE ary;

if (rb_block_given_p())
ary = Qnil;
else
ary = rb_ary_new();

FilePathValue(str);

ary = rb_ary_new();
p = RSTRING(str)->ptr;
pend = p + RSTRING(str)->len;

Expand All @@ -1497,6 +1486,10 @@ rb_push_glob(str, flags) /* '\0' is delimiter */
else p++;
}

if (rb_block_given_p()) {
rb_ary_each(ary);
return Qnil;
}
return ary;
}

Expand Down
31 changes: 8 additions & 23 deletions enum.c
Expand Up @@ -117,11 +117,8 @@ enum_find(argc, argv, obj)
rb_scan_args(argc, argv, "01", &if_none);
rb_iterate(rb_each, obj, find_i, (VALUE)memo);
if (memo->u2.value) {
VALUE result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
return memo->u1.value;
}
rb_gc_force_recycle((VALUE)memo);
if (!NIL_P(if_none)) {
return rb_funcall(if_none, rb_intern("call"), 0, 0);
}
Expand Down Expand Up @@ -319,7 +316,6 @@ enum_inject(argc, argv, obj)
}
rb_iterate(rb_each, obj, inject_i, (VALUE)memo);
n = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return n;
}

Expand Down Expand Up @@ -401,17 +397,14 @@ sort_by_i(i, ary)
return Qnil;
}

static VALUE
sort_by_cmp(values, ary)
VALUE values, ary;
static int
sort_by_cmp(aa, bb)
NODE **aa, **bb;
{
NODE *a = (NODE*)RARRAY(values)->ptr[0];
NODE *b = (NODE*)RARRAY(values)->ptr[1];
VALUE a = aa[0]->u1.value;
VALUE b = bb[0]->u1.value;

/* pedantic check; they must be memo nodes */
Check_Type(a, T_NODE);
Check_Type(b, T_NODE);
return rb_funcall(a->u1.value, id_cmp, 1, b->u1.value);
return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b);
}

/*
Expand Down Expand Up @@ -499,7 +492,7 @@ enum_sort_by(obj)
RBASIC(ary)->klass = 0;
rb_iterate(rb_each, obj, sort_by_i, ary);
if (RARRAY(ary)->len > 1) {
rb_iterate(rb_ary_sort_bang, ary, sort_by_cmp, ary);
qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
}
for (i=0; i<RARRAY(ary)->len; i++) {
RARRAY(ary)->ptr[i] = RNODE(RARRAY(ary)->ptr[i])->u2.value;
Expand Down Expand Up @@ -559,7 +552,6 @@ enum_all(obj)
memo->u1.value = Qtrue;
rb_iterate(rb_each, obj, rb_block_given_p() ? all_iter_i : all_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -615,7 +607,6 @@ enum_any(obj)
memo->u1.value = Qfalse;
rb_iterate(rb_each, obj, rb_block_given_p() ? any_iter_i : any_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -681,7 +672,6 @@ enum_min(obj)

rb_iterate(rb_each, obj, rb_block_given_p() ? min_ii : min_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -746,7 +736,6 @@ enum_max(obj)

rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -789,7 +778,6 @@ enum_min_by(obj)

rb_iterate(rb_each, obj, min_by_i, (VALUE)memo);
result = memo->u2.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -832,7 +820,6 @@ enum_max_by(obj)

rb_iterate(rb_each, obj, max_by_i, (VALUE)memo);
result = memo->u2.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -870,7 +857,6 @@ enum_member(obj, val)

rb_iterate(rb_each, obj, member_i, (VALUE)memo);
result = memo->u2.value;
rb_gc_force_recycle((VALUE)memo);
return result;
}

Expand Down Expand Up @@ -906,7 +892,6 @@ enum_each_with_index(obj)
NODE *memo = rb_node_newnode(NODE_MEMO, 0, 0, 0);

rb_iterate(rb_each, obj, each_with_index_i, (VALUE)memo);
rb_gc_force_recycle((VALUE)memo);
return obj;
}

Expand Down
6 changes: 3 additions & 3 deletions eval.c
Expand Up @@ -8264,7 +8264,7 @@ proc_eq(self, other)
*/

static VALUE
proc_hash(self, other)
proc_hash(self)
VALUE self;
{
struct BLOCK *data;
Expand All @@ -8288,8 +8288,8 @@ proc_hash(self, other)
*/

static VALUE
proc_to_s(self, other)
VALUE self, other;
proc_to_s(self)
VALUE self;
{
struct BLOCK *data;
NODE *node;
Expand Down
2 changes: 1 addition & 1 deletion ext/bigdecimal/bigdecimal.c
Expand Up @@ -579,7 +579,7 @@ BigDecimal_ge(VALUE self, VALUE r)
}

static VALUE
BigDecimal_neg(VALUE self, VALUE r)
BigDecimal_neg(VALUE self)
{
ENTER(5);
Real *c, *a;
Expand Down
2 changes: 1 addition & 1 deletion ext/dbm/dbm.c
Expand Up @@ -734,7 +734,7 @@ Init_dbm()
rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);
rb_define_method(rb_cDBM, "store", fdbm_store, 2);
rb_define_method(rb_cDBM, "index", fdbm_index, 1);
rb_define_method(rb_cDBM, "select", fdbm_select, -1);
rb_define_method(rb_cDBM, "select", fdbm_select, 0);
rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fdbm_length, 0);
rb_define_method(rb_cDBM, "size", fdbm_length, 0);
Expand Down
3 changes: 0 additions & 3 deletions ext/enumerator/enumerator.c
Expand Up @@ -70,7 +70,6 @@ enum_each_slice(obj, n)
ary = memo->u1.value;
if (RARRAY(ary)->len > 0) rb_yield(ary);

rb_gc_force_recycle((VALUE)memo);
return Qnil;
}

Expand Down Expand Up @@ -114,7 +113,6 @@ enum_each_cons(obj, n)

rb_iterate(rb_each, obj, each_cons_i, (VALUE)memo);

rb_gc_force_recycle((VALUE)memo);
return Qnil;
}

Expand Down Expand Up @@ -163,7 +161,6 @@ enumerator_each(obj)
rb_to_id(rb_ivar_get(obj, id_enum_method)),
rb_ivar_get(obj, id_enum_args));
val = rb_iterate((VALUE (*)_((VALUE)))enumerator_iter, obj, rb_yield, 0);
rb_gc_force_recycle(obj);
return val;
}

Expand Down
16 changes: 7 additions & 9 deletions ext/socket/socket.c
Expand Up @@ -2217,27 +2217,25 @@ sock_s_getservbyaname(argc, argv)
int argc;
VALUE *argv;
{
VALUE service, protocol;
char *proto;
VALUE service, proto;
struct servent *sp;
int port;

rb_scan_args(argc, argv, "11", &service, &protocol);
if (NIL_P(protocol)) proto = "tcp";
else proto = StringValuePtr(protocol);
rb_scan_args(argc, argv, "11", &service, &proto);
if (NIL_P(proto)) proto = rb_str_new2("tcp");
else StringValue(proto);

StringValue(service);
sp = getservbyname((char*)RSTRING(service)->ptr, proto);
sp = getservbyname((char*)RSTRING(service)->ptr, RSTRING(proto)->ptr);
if (sp) {
port = ntohs(sp->s_port);
}
else {
char *s = RSTRING(service)->ptr;
char *s = StringValuePtr(service);
char *end;

port = strtoul(s, &end, 0);
if (*end != '\0') {
rb_raise(rb_eSocket, "no such service %s/%s", s, proto);
rb_raise(rb_eSocket, "no such service %s/%s", s, RSTRING(proto)->ptr);
}
}
return INT2FIX(port);
Expand Down
6 changes: 3 additions & 3 deletions ext/win32ole/win32ole.c
Expand Up @@ -2758,7 +2758,7 @@ static VALUE
fole_get_methods( self )
VALUE self;
{
return ole_methods( self, INVOKE_PROPERTYGET);
return ole_methods(self, INVOKE_PROPERTYGET);
}

/*
Expand All @@ -2770,7 +2770,7 @@ static VALUE
fole_put_methods( self )
VALUE self;
{
return ole_methods( self, INVOKE_PROPERTYPUT);
return ole_methods(self, INVOKE_PROPERTYPUT);
}

/*
Expand All @@ -2782,7 +2782,7 @@ static VALUE
fole_func_methods( self )
VALUE self;
{
return ole_methods( self, INVOKE_FUNC);
return ole_methods(self, INVOKE_FUNC);
}

/*
Expand Down
3 changes: 2 additions & 1 deletion ext/zlib/zlib.c
Expand Up @@ -439,6 +439,7 @@ zstream_expand_buffer(z)
z->buf_filled = 0;
z->stream.next_out = RSTRING(z->buf)->ptr;
z->stream.avail_out = ZSTREAM_INITIAL_BUFSIZE;
RBASIC(z->buf)->klass = 0;
return;
}

Expand Down Expand Up @@ -3380,7 +3381,7 @@ void Init_zlib()
cZStream = rb_define_class_under(mZlib, "ZStream", rb_cObject);
rb_undef_alloc_func(cZStream);
rb_define_method(cZStream, "avail_out", rb_zstream_avail_out, 0);
rb_define_method(cZStream, "avail_out=", rb_zstream_set_avail_out, 0);
rb_define_method(cZStream, "avail_out=", rb_zstream_set_avail_out, 1);
rb_define_method(cZStream, "avail_in", rb_zstream_avail_in, 0);
rb_define_method(cZStream, "total_in", rb_zstream_total_in, 0);
rb_define_method(cZStream, "total_out", rb_zstream_total_out, 0);
Expand Down

0 comments on commit 1057902

Please sign in to comment.