From ae2d632c66fa59c3ab8c425f4743faf11fe5e4bc Mon Sep 17 00:00:00 2001 From: shyouhei Date: Tue, 21 Aug 2007 23:52:26 +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_6@13146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ variable.c | 11 ++++++++--- version.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfb4ed9dd3..be7b4e70b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Aug 22 08:52:02 2007 Nobuyoshi Nakada + + * variable.c (rb_path2class): get rid of dangling pointer caused by + optimized out value. + Wed Aug 22 08:51:20 2007 NAKAMURA Usaku * ext/dl/lib/dl/win32.rb: seems that dl doesn't accept void argument. diff --git a/variable.c b/variable.c index 44e2403639..e00f1ef6eb 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; diff --git a/version.h b/version.h index afdb718b92..64f269bb45 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2007-08-22" #define RUBY_VERSION_CODE 186 #define RUBY_RELEASE_CODE 20070822 -#define RUBY_PATCHLEVEL 47 +#define RUBY_PATCHLEVEL 48 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 -- cgit v1.2.3