summaryrefslogtreecommitdiff
path: root/load.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-16 06:26:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-16 06:26:33 +0000
commitdb26a9b105f0e2b4850c45554c1e77aa35973ef4 (patch)
tree33bed36b99a8590dd8868b286423a8937419679d /load.c
parent2402ecabb064525651667374a0f758321bbc7f65 (diff)
* 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
Diffstat (limited to 'load.c')
-rw-r--r--load.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/load.c b/load.c
index 541e6c81bc..1d10589611 100644
--- a/load.c
+++ b/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;