Skip to content

Commit 5a322df

Browse files
author
(no author)
committed
This commit was manufactured by cvs2svn to create tag 'v1_8_5_9'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_9@11389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 74483e1 commit 5a322df

File tree

12 files changed

+223
-87
lines changed

12 files changed

+223
-87
lines changed

ChangeLog

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
Thu Dec 14 23:37:38 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* dir.c (glob_helper): get rid of possible memory leak.
4+
5+
* win32/win32.c (cmdglob, rb_w32_cmdvector, rb_w32_opendir,
6+
rb_w32_get_environ): not to use GC before initialization.
7+
8+
Wed Dec 6 19:53:41 2006 WATANABE Hirofumi <eban@ruby-lang.org>
9+
10+
* configure.in (SITE_DIR): fixed to emtpy RUBY_SITE_LIB in config.h on
11+
NetBSD. fixed: [ruby-dev:29358]
12+
13+
Mon Dec 4 10:43:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
14+
15+
* parse.y (dyna_init_gen): dvar initialization only if dvar is
16+
assigned inner block. [ruby-talk:227402]
17+
18+
Mon Dec 4 10:22:26 2006 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
19+
20+
* stable version 1.8.5-p2 relased.
21+
22+
Sun Dec 3 17:11:12 2006 Shugo Maeda <shugo@ruby-lang.org>
23+
24+
* lib/cgi.rb (CGI::QueryExtension::read_multipart): should quote
25+
boundary. JVN#84798830
26+
27+
Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
28+
29+
* version.h: addition of RUBY_PATCHLEVEL.
30+
* version.c: ditto.
31+
32+
Fri Nov 24 10:17:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
33+
34+
* bignum.c (bignorm): avoid segmentation. a patch from Hiroyuki
35+
Ito <ZXB01226@nifty.com>. [ruby-list:43012]
36+
37+
Thu Nov 2 15:43:39 2006 NAKAMURA Usaku <usa@ruby-lang.org>
38+
39+
* parse.y (primary): should set NODE even when compstmt is NULL.
40+
merge from trunk. fixed: [ruby-dev:29732]
41+
42+
Sat Sep 23 21:34:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
43+
44+
* lib/cgi.rb (CGI::QueryExtension::read_multipart): CGI content
45+
may be empty. a patch from Jamis Buck <jamis at 37signals.com>.
46+
47+
Mon Sep 4 21:43:57 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
48+
49+
* ext/dbm/extconf.rb: create makefile according to the result of check
50+
for dbm header. fixed: [ruby-dev:29445]
51+
52+
Tue Aug 29 19:10:10 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
53+
54+
* hash.c (rb_hash_s_create): fixed memory leak, based on the patch
55+
by Kent Sibilev <ksruby at gmail.com>. fixed: [ruby-talk:211233]
56+
57+
Fri Aug 25 17:15:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
58+
59+
* stable version 1.8.5 released.
60+
161
Fri Aug 25 17:02:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
262

363
* gc.c (gc_sweep): typo fixed.

bignum.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ static VALUE
9999
bignorm(x)
100100
VALUE x;
101101
{
102-
if (!FIXNUM_P(x)) {
102+
if (FIXNUM_P(x)) {
103+
return x;
104+
}
105+
else if (TYPE(x) == T_BIGNUM) {
103106
long len = RBIGNUM(x)->len;
104107
BDIGIT *ds = BDIGITS(x);
105108

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ AC_ARG_WITH(sitedir,
15191519
[ --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
15201520
[sitedir=$withval],
15211521
[sitedir='${prefix}/lib/ruby/site_ruby'])
1522-
SITE_DIR="`eval \"echo ${sitedir}\"`"
1522+
SITE_DIR=`eval echo \\"${sitedir}\\"`
15231523
case "$target_os" in
15241524
cygwin*|mingw*|*djgpp*|os2-emx*)
15251525
RUBY_SITE_LIB_PATH="`expr "$SITE_DIR" : "$prefix\(/.*\)"`" ||

dir.c

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fnmatch(pat, string, flags)
158158
int period = !(flags & FNM_DOTMATCH);
159159
int nocase = flags & FNM_CASEFOLD;
160160

161-
while (c = *pat++) {
161+
while ((c = *pat++) != '\0') {
162162
switch (c) {
163163
case '?':
164164
if (!*s || ISDIRSEP(*s) || PERIOD(s))
@@ -821,7 +821,12 @@ sys_warning_1(mesg)
821821

822822
#define GLOB_VERBOSE (1U << (sizeof(int) * CHAR_BIT - 1))
823823
#define sys_warning(val) \
824-
((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val), 0))
824+
(void)((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val), 0))
825+
826+
#define GLOB_ALLOC(type) (type *)malloc(sizeof(type))
827+
#define GLOB_ALLOC_N(type, n) (type *)malloc(sizeof(type) * (n))
828+
#define GLOB_REALLOC_N(var, type, n) (type *)realloc((var), sizeof(type) * (n))
829+
#define GLOB_JUMP_TAG(status) ((status == -1) ? rb_memerror() : rb_jump_tag(status))
825830

826831
/* Return nonzero if S has any special globbing chars in it. */
827832
static int
@@ -872,7 +877,8 @@ extract_path(p, pend)
872877
int len;
873878

874879
len = pend - p;
875-
alloc = ALLOC_N(char, len+1);
880+
alloc = GLOB_ALLOC_N(char, len+1);
881+
if (!alloc) return NULL;
876882
memcpy(alloc, p, len);
877883
if (len > 1 && pend[-1] == '/'
878884
#if defined DOSISH_DRIVE_LETTER
@@ -955,6 +961,7 @@ glob_helper(path, sub, flags, func, arg)
955961
int status = 0;
956962
char *buf = 0;
957963
char *newpath = 0;
964+
char *newbuf;
958965

959966
p = sub ? sub : path;
960967
if (!has_magic(p, 0, flags)) {
@@ -963,6 +970,7 @@ glob_helper(path, sub, flags, func, arg)
963970
#endif
964971
{
965972
newpath = strdup(path);
973+
if (!newpath) return -1;
966974
if (sub) {
967975
p = newpath + (sub - path);
968976
remove_backslashes(newpath + (sub - path));
@@ -981,7 +989,7 @@ glob_helper(path, sub, flags, func, arg)
981989
we may want to know what is wrong. */
982990
sys_warning(path);
983991
}
984-
xfree(newpath);
992+
if (newpath) free(newpath);
985993
return status;
986994
}
987995

@@ -1000,10 +1008,18 @@ glob_helper(path, sub, flags, func, arg)
10001008
} *tmp, *link, **tail = &link;
10011009

10021010
base = extract_path(path, p);
1011+
if (!base) {
1012+
status = -1;
1013+
break;
1014+
}
10031015
if (path == p) dir = ".";
10041016
else dir = base;
10051017

10061018
magic = extract_elem(p);
1019+
if (!magic) {
1020+
status = -1;
1021+
break;
1022+
}
10071023
if (stat(dir, &st) < 0) {
10081024
if (errno != ENOENT)
10091025
sys_warning(dir);
@@ -1015,7 +1031,12 @@ glob_helper(path, sub, flags, func, arg)
10151031
if (m && strcmp(magic, "**") == 0) {
10161032
int n = strlen(base);
10171033
recursive = 1;
1018-
REALLOC_N(buf, char, n+strlen(m)+3);
1034+
newbuf = GLOB_REALLOC_N(buf, char, n+strlen(m)+3);
1035+
if (!newbuf) {
1036+
status = -1;
1037+
goto finalize;
1038+
}
1039+
buf = newbuf;
10191040
sprintf(buf, "%s%s", base, *base ? m : m+1);
10201041
status = glob_helper(buf, buf+n, flags, func, arg);
10211042
if (status) goto finalize;
@@ -1046,7 +1067,12 @@ glob_helper(path, sub, flags, func, arg)
10461067
continue;
10471068
if (fnmatch("*", dp->d_name, flags) != 0)
10481069
continue;
1049-
REALLOC_N(buf, char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
1070+
newbuf = GLOB_REALLOC_N(buf, char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
1071+
if (!newbuf) {
1072+
status = -1;
1073+
break;
1074+
}
1075+
buf = newbuf;
10501076
sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
10511077
if (lstat(buf, &st) < 0) {
10521078
if (errno != ENOENT)
@@ -1064,14 +1090,23 @@ glob_helper(path, sub, flags, func, arg)
10641090
continue;
10651091
}
10661092
if (fnmatch(magic, dp->d_name, flags) == 0) {
1067-
REALLOC_N(buf, char, strlen(base)+NAMLEN(dp)+2);
1093+
newbuf = GLOB_REALLOC_N(buf, char, strlen(base)+NAMLEN(dp)+2);
1094+
if (!newbuf) {
1095+
status = -1;
1096+
break;
1097+
}
1098+
buf = newbuf;
10681099
sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
10691100
if (!m) {
10701101
status = glob_call_func(func, buf, arg);
10711102
if (status) break;
10721103
continue;
10731104
}
1074-
tmp = ALLOC(struct d_link);
1105+
tmp = GLOB_ALLOC(struct d_link);
1106+
if (!tmp) {
1107+
status = -1;
1108+
break;
1109+
}
10751110
tmp->path = buf;
10761111
buf = 0;
10771112
*tail = tmp;
@@ -1091,7 +1126,12 @@ glob_helper(path, sub, flags, func, arg)
10911126
int len = strlen(link->path);
10921127
int mlen = strlen(m);
10931128

1094-
REALLOC_N(buf, char, len+mlen+1);
1129+
newbuf = GLOB_REALLOC_N(buf, char, len+mlen+1);
1130+
if (!newbuf) {
1131+
status = -1;
1132+
goto next_elem;
1133+
}
1134+
buf = newbuf;
10951135
sprintf(buf, "%s%s", link->path, m);
10961136
status = glob_helper(buf, buf+len, flags, func, arg);
10971137
}
@@ -1100,6 +1140,7 @@ glob_helper(path, sub, flags, func, arg)
11001140
sys_warning(link->path);
11011141
}
11021142
}
1143+
next_elem:
11031144
tmp = link;
11041145
link = link->next;
11051146
free(tmp->path);
@@ -1110,8 +1151,8 @@ glob_helper(path, sub, flags, func, arg)
11101151
}
11111152
p = m;
11121153
}
1113-
xfree(buf);
1114-
xfree(newpath);
1154+
if (buf) free(buf);
1155+
if (newpath) free(newpath);
11151156
return status;
11161157
}
11171158

@@ -1211,7 +1252,7 @@ push_braces(ary, str, flags)
12111252
int flags;
12121253
{
12131254
char *buf = 0;
1214-
char *b;
1255+
char *b, *newbuf;
12151256
const char *s, *p, *t;
12161257
const char *lbrace, *rbrace;
12171258
int nest = 0;
@@ -1249,7 +1290,12 @@ push_braces(ary, str, flags)
12491290
}
12501291
}
12511292
}
1252-
REALLOC_N(buf, char, len+1);
1293+
newbuf = GLOB_REALLOC_N(buf, char, len+1);
1294+
if (!newbuf) {
1295+
status = -1;
1296+
break;
1297+
}
1298+
buf = newbuf;
12531299
memcpy(buf, s, lbrace-s);
12541300
b = buf + (lbrace-s);
12551301
memcpy(b, t, p-t);
@@ -1261,7 +1307,7 @@ push_braces(ary, str, flags)
12611307
else {
12621308
status = push_globs(ary, str, flags);
12631309
}
1264-
xfree(buf);
1310+
if (buf) free(buf);
12651311

12661312
return status;
12671313
}
@@ -1306,7 +1352,7 @@ rb_push_glob(str, flags)
13061352
}
13071353
/* else unmatched braces */
13081354
}
1309-
if (status) rb_jump_tag(status);
1355+
if (status) GLOB_JUMP_TAG(status);
13101356
if (rb_block_given_p()) {
13111357
rb_ary_each(ary);
13121358
return Qnil;

ext/dbm/extconf.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ def db_prefix(func)
4646
end
4747

4848
if dblib
49-
db_check(dblib)
49+
dbm_hdr = db_check(dblib)
5050
else
51-
for dblib in %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
52-
db_check(dblib) and break
51+
dbm_hdr = %w(db db2 db1 dbm gdbm gdbm_compat qdbm).any? do |dblib|
52+
db_check(dblib)
5353
end
5454
end
5555

5656
have_header("cdefs.h")
5757
have_header("sys/cdefs.h")
58-
if /DBM_HDR/ =~ $CFLAGS and have_func(db_prefix("dbm_open"))
58+
if dbm_hdr and have_func(db_prefix("dbm_open"))
5959
have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm
6060
create_makefile("dbm")
6161
end

hash.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,31 @@ rb_hash_foreach(hash, func, farg)
223223
rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
224224
}
225225

226+
static VALUE hash_alloc0 _((VALUE));
226227
static VALUE hash_alloc _((VALUE));
227228
static VALUE
228-
hash_alloc(klass)
229+
hash_alloc0(klass)
229230
VALUE klass;
230231
{
231232
NEWOBJ(hash, struct RHash);
232233
OBJSETUP(hash, klass, T_HASH);
233234

234235
hash->ifnone = Qnil;
235-
hash->tbl = st_init_table(&objhash);
236236

237237
return (VALUE)hash;
238238
}
239239

240+
static VALUE
241+
hash_alloc(klass)
242+
VALUE klass;
243+
{
244+
VALUE hash = hash_alloc0(klass);
245+
246+
RHASH(hash)->tbl = st_init_table(&objhash);
247+
248+
return hash;
249+
}
250+
240251
VALUE
241252
rb_hash_new()
242253
{
@@ -325,9 +336,7 @@ rb_hash_s_create(argc, argv, klass)
325336
int i;
326337

327338
if (argc == 1 && TYPE(argv[0]) == T_HASH) {
328-
hash = hash_alloc(klass);
329-
330-
RHASH(hash)->ifnone = Qnil;
339+
hash = hash_alloc0(klass);
331340
RHASH(hash)->tbl = st_copy(RHASH(argv[0])->tbl);
332341

333342
return hash;

ia64.s

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)