* load.c (rb_feature_p): get rid of unlimited alloca.

* object.c (rb_cstr_to_dbl): ditto.

* io.c (mode_enc): fixed uninitialized variable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-01-16 06:26:33 +00:00
Родитель 2402ecabb0
Коммит db26a9b105
4 изменённых файлов: 29 добавлений и 10 удалений

Просмотреть файл

@ -1,9 +1,21 @@
Wed Jan 16 14:55:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
Wed Jan 16 15:26:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (rb_feature_p): get rid of unlimited alloca.
* object.c (rb_cstr_to_dbl): ditto.
* io.c (mode_enc): fixed uninitialized variable.
* file.c (sys_fail2): get rid of unlimited alloca.
* io.c (mode_enc, pipe_open, rb_io_s_popen): ditto.
* load.c (rb_feature_p): ditto.
* object.c (rb_cstr_to_dbl): ditto.
* io.c (mode_enc): fixed uninitialized variable.
Wed Jan 16 12:51:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/intern.h (rb_str_tmp_new, rb_str_shared_replace):

7
io.c
Просмотреть файл

@ -3192,14 +3192,15 @@ mode_enc(rb_io_t *fptr, const char *estr)
enc2name = ALLOCA_N(char, n+1);
memcpy(enc2name, estr, n);
enc2name[n] = '\0';
estr = enc2name;
idx2 = rb_enc_find_index(enc2name);
}
if (idx2 < 0) {
rb_warn("Unsupported encoding %s ignored", enc2name);
rb_warn("Unsupported encoding %.*s ignored", n, estr);
}
else if (idx2 == idx) {
rb_warn("Ignoring internal encoding %s: it is identical to external encoding %s",
enc2name, p1);
rb_warn("Ignoring internal encoding %.*s: it is identical to external encoding %s",
n, estr, p1);
}
else {
fptr->enc2 = rb_enc_from_index(idx2);

6
load.c
Просмотреть файл

@ -166,18 +166,22 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
return !IS_RBEXT(ext) ? 's' : 'r';
}
else {
VALUE bufstr;
char *buf;
if (ext && *ext) return 0;
buf = ALLOCA_N(char, len + DLEXT_MAXLEN + 1);
bufstr = rb_str_tmp_new(len + DLEXT_MAXLEN);
buf = RSTRING_PTR(bufstr);
MEMCPY(buf, feature, char, len);
for (i = 0; (e = loadable_ext[i]) != 0; i++) {
strncpy(buf + len, e, DLEXT_MAXLEN + 1);
if (st_get_key(loading_tbl, (st_data_t)buf, &data)) {
rb_str_resize(bufstr, 0);
if (fn) *fn = (const char*)data;
return i ? 's' : 'r';
}
}
rb_str_resize(bufstr, 0);
}
}
return 0;

Просмотреть файл

@ -19,6 +19,7 @@
#include <errno.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
VALUE rb_cBasicObject;
VALUE rb_mKernel;
@ -2048,15 +2049,16 @@ rb_cstr_to_dbl(const char *p, int badcheck)
return d;
}
if (*end) {
char *buf = ALLOCA_N(char, strlen(p)+1);
char buf[DBL_DIG * 4 + 10];
char *n = buf;
char *e = buf + sizeof(buf) - 1;
while (p < end) *n++ = *p++;
while (*p) {
while (p < end && n < e) *n++ = *p++;
while (n < e && *p) {
if (*p == '_') {
/* remove underscores between digits */
if (n == buf || !ISDIGIT(n[-1])) goto bad;
while (*++p == '_');
if (n == buf || !ISDIGIT(n[-1])) goto bad;
while (*++p == '_');
if (!ISDIGIT(*p)) {
if (badcheck) goto bad;
break;