From f1534dd543df3253520f5f27cafeb10a734deabe Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 15 Aug 2007 19:31:03 +0000 Subject: * variable.c (rb_path2class): get rid of dangling pointer caused by optimized out value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@12962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index a51dd9ea58..4231a75827 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; -- cgit v1.2.3