summaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-21 23:52:26 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-21 23:52:26 +0000
commit34cce3081e785f7127b731dcee5c3283e3ee873a (patch)
tree39776ca4954b7b2c4bd7facf2c60dabaf13bcfbb /variable.c
parent66b06bc7866ac58960dfd7c2d1d0fd5368acbdfd (diff)
downloadruby-34cce3081e785f7127b731dcee5c3283e3ee873a.tar.gz
ruby-34cce3081e785f7127b731dcee5c3283e3ee873a.tar.xz
ruby-34cce3081e785f7127b731dcee5c3283e3ee873a.zip
* variable.c (rb_path2class): get rid of dangling pointer caused by
optimized out value. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6@13146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/variable.c b/variable.c
index 44e240363..e00f1ef6e 100644
--- a/variable.c
+++ b/variable.c
@@ -241,16 +241,21 @@ rb_path2class(path)
const char *pbeg, *p;
ID id;
VALUE c = rb_cObject;
+ VALUE str = 0;
if (path[0] == '#') {
rb_raise(rb_eArgError, "can't retrieve anonymous class %s", path);
}
pbeg = p = path;
while (*p) {
- VALUE str;
-
while (*p && *p != ':') p++;
- str = rb_str_new(pbeg, p-pbeg);
+ if (str) {
+ RSTRING(str)->len = 0;
+ rb_str_cat(str, pbeg, p-pbeg);
+ }
+ else {
+ str = rb_str_new(pbeg, p-pbeg);
+ }
id = rb_intern(RSTRING(str)->ptr);
if (p[0] == ':') {
if (p[1] != ':') goto undefined_class;