Skip to content

Commit 85911c4

Browse files
author
matz
committed
* ext/socket/socket.c (tcp_s_gethostbyname): was using
uninitialized size_t value. [ruby-talk:76946] * Minor cleanups. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 43601a1 commit 85911c4

File tree

14 files changed

+55
-48
lines changed

14 files changed

+55
-48
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Fri Jul 25 14:34:55 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
2+
3+
* ext/socket/socket.c (tcp_s_gethostbyname): was using
4+
uninitialized size_t value. [ruby-talk:76946]
5+
16
Fri Jul 25 13:38:38 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
27

38
* re.c (rb_reg_options_m): use rb_reg_options() to mask internal

array.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ rb_ary_and(ary1, ary2)
18171817

18181818
for (i=0; i<RARRAY(ary1)->len; i++) {
18191819
VALUE v = RARRAY(ary1)->ptr[i];
1820-
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
1820+
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
18211821
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
18221822
}
18231823
}
@@ -1839,13 +1839,13 @@ rb_ary_or(ary1, ary2)
18391839

18401840
for (i=0; i<RARRAY(ary1)->len; i++) {
18411841
v = RARRAY(ary1)->ptr[i];
1842-
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
1842+
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
18431843
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
18441844
}
18451845
}
18461846
for (i=0; i<RARRAY(ary2)->len; i++) {
18471847
v = RARRAY(ary2)->ptr[i];
1848-
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
1848+
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
18491849
rb_ary_push(ary3, RARRAY(ary2)->ptr[i]);
18501850
}
18511851
}
@@ -1870,7 +1870,7 @@ rb_ary_uniq_bang(ary)
18701870
end = p + RARRAY(ary)->len;
18711871
while (p < end) {
18721872
VALUE v = *p;
1873-
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
1873+
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
18741874
*q++ = *p;
18751875
}
18761876
p++;

class.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ rb_mod_clone(module)
7272

7373
RCLASS(clone)->iv_tbl = st_copy(RCLASS(module)->iv_tbl);
7474
id = rb_intern("__classpath__");
75-
st_delete(RCLASS(clone)->iv_tbl, &id, 0);
75+
st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
7676
id = rb_intern("__classid__");
77-
st_delete(RCLASS(clone)->iv_tbl, &id, 0);
77+
st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
7878
}
7979
if (RCLASS(module)->m_tbl) {
8080
RCLASS(clone)->m_tbl = st_init_numtable();

dln.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ load_1(fd, disp, need_init)
675675
char *key = sym->n_un.n_name;
676676

677677
if (st_lookup(sym_tbl, sym[1].n_un.n_name, &old_sym)) {
678-
if (st_delete(undef_tbl, &key, NULL)) {
678+
if (st_delete(undef_tbl, (st_data_t*)&key, NULL)) {
679679
unlink_undef(key, old_sym->n_value);
680680
free(key);
681681
}
@@ -688,7 +688,7 @@ load_1(fd, disp, need_init)
688688
st_foreach(reloc_tbl, reloc_repl, &data);
689689

690690
st_insert(undef_tbl, strdup(sym[1].n_un.n_name), NULL);
691-
if (st_delete(undef_tbl, &key, NULL)) {
691+
if (st_delete(undef_tbl, (st_data_t*)&key, NULL)) {
692692
free(key);
693693
}
694694
}
@@ -756,7 +756,7 @@ load_1(fd, disp, need_init)
756756
}
757757

758758
key = sym->n_un.n_name;
759-
if (st_delete(undef_tbl, &key, NULL) != 0) {
759+
if (st_delete(undef_tbl, (st_data_t*)&key, NULL) != 0) {
760760
unlink_undef(key, sym->n_value);
761761
free(key);
762762
}

eval.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8206,7 +8206,7 @@ rb_thread_save_context(th)
82068206
}
82078207

82088208
static int
8209-
thread_switch(n)
8209+
rb_thread_switch(n)
82108210
int n;
82118211
{
82128212
rb_trap_immediate = (curr_thread->flags&0x100)?1:0;
@@ -8239,7 +8239,7 @@ thread_switch(n)
82398239

82408240
#define THREAD_SAVE_CONTEXT(th) \
82418241
(rb_thread_save_context(th),\
8242-
thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
8242+
rb_thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
82438243

82448244
static void rb_thread_restore_context _((rb_thread_t,int));
82458245

@@ -9137,21 +9137,21 @@ rb_thread_safe_level(thread)
91379137
return INT2NUM(th->safe);
91389138
}
91399139

9140-
static int thread_abort;
9140+
static int ruby_thread_abort;
91419141
static VALUE thgroup_default;
91429142

91439143
static VALUE
91449144
rb_thread_s_abort_exc()
91459145
{
9146-
return thread_abort?Qtrue:Qfalse;
9146+
return ruby_thread_abort?Qtrue:Qfalse;
91479147
}
91489148

91499149
static VALUE
91509150
rb_thread_s_abort_exc_set(self, val)
91519151
VALUE self, val;
91529152
{
91539153
rb_secure(4);
9154-
thread_abort = RTEST(val);
9154+
ruby_thread_abort = RTEST(val);
91559155
return val;
91569156
}
91579157

@@ -9380,7 +9380,7 @@ rb_thread_start_0(fn, arg, th_arg)
93809380
rb_thread_raise(1, &ruby_errinfo, main_thread);
93819381
}
93829382
}
9383-
else if (th->safe < 4 && (thread_abort || th->abort || RTEST(ruby_debug))) {
9383+
else if (th->safe < 4 && (ruby_thread_abort || th->abort || RTEST(ruby_debug))) {
93849384
VALUE err = system_exit(1, 0, 0);
93859385
error_print();
93869386
/* exit on main_thread */
@@ -9733,7 +9733,7 @@ rb_thread_local_aset(thread, id, val)
97339733
th->locals = st_init_numtable();
97349734
}
97359735
if (NIL_P(val)) {
9736-
st_delete(th->locals, &id, 0);
9736+
st_delete(th->locals, (st_data_t*)&id, 0);
97379737
return Qnil;
97389738
}
97399739
st_insert(th->locals, id, val);

ext/socket/socket.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,6 @@ tcp_s_gethostbyname(obj, host)
10921092
struct hostent *h = sock_hostbyname(host);
10931093
VALUE ary, names;
10941094
char **pch;
1095-
size_t size;
10961095

10971096
ary = rb_ary_new();
10981097
rb_ary_push(ary, rb_str_new2(h->h_name));
@@ -1124,7 +1123,7 @@ tcp_s_gethostbyname(obj, host)
11241123
#ifdef SIN6_LEN
11251124
sin6.sin6_len = sizeof(sin6);
11261125
#endif
1127-
memcpy((char*)&sin6.sin6_addr, *pch, size);
1126+
memcpy((char*)&sin6.sin6_addr, *pch, h->h_length);
11281127
rb_ary_push(ary, mkipaddr((struct sockaddr*)&sin6));
11291128
break;
11301129
}

ext/syck/emitter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ syck_emitter_flush( SyckEmitter *e, long check_room )
192192
{
193193
char *header = S_ALLOC_N( char, 64 );
194194
S_MEMZERO( header, char, 64 );
195-
sprintf( header, "--- %YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR );
195+
sprintf( header, "--- %%YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR );
196196
(e->handler)( e, header, strlen( header ) );
197197
S_FREE( header );
198198
}

file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,7 @@ rb_file_s_lchmod(argc, argv)
10511051
VALUE *argv;
10521052
{
10531053
rb_notimplement();
1054+
return Qnil; /* not reached */
10541055
}
10551056
#endif
10561057

gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ undefine_final(os, obj)
14591459
VALUE os, obj;
14601460
{
14611461
if (finalizer_table) {
1462-
st_delete(finalizer_table, &obj, 0);
1462+
st_delete(finalizer_table, (st_data_t*)&obj, 0);
14631463
}
14641464
return obj;
14651465
}
@@ -1533,7 +1533,7 @@ run_final(obj)
15331533
args[0] = RARRAY(finalizers)->ptr[i];
15341534
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
15351535
}
1536-
if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
1536+
if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
15371537
for (i=0; i<RARRAY(table)->len; i++) {
15381538
args[0] = RARRAY(table)->ptr[i];
15391539
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);

hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,12 @@ rb_hash_delete(hash, key)
407407

408408
rb_hash_modify(hash);
409409
if (RHASH(hash)->iter_lev > 0) {
410-
if (st_delete_safe(RHASH(hash)->tbl, &key, &val, Qundef)) {
410+
if (st_delete_safe(RHASH(hash)->tbl, (st_data_t*)&key, &val, Qundef)) {
411411
FL_SET(hash, HASH_DELETED);
412412
return val;
413413
}
414414
}
415-
else if (st_delete(RHASH(hash)->tbl, &key, &val))
415+
else if (st_delete(RHASH(hash)->tbl, (st_data_t*)&key, &val))
416416
return val;
417417
if (rb_block_given_p()) {
418418
return rb_yield(key);

0 commit comments

Comments
 (0)