From 2f0e3675761d7cd589bc6d43d3a6cd73fa89f0a1 Mon Sep 17 00:00:00 2001 From: mame Date: Sun, 1 Aug 2010 15:44:38 +0000 Subject: * util.c (ruby_add_suffix): fixed a bug returning uninitialized value. This is the essential part from r28794 of trunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ util.c | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4fe81b873..7c3b0a21d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 2 00:03:18 2010 Yusuke Endoh + + * util.c (ruby_add_suffix): fixed a bug returning uninitialized value. + This is the essential part from r28794 of trunk. + Mon Jul 26 13:01:25 2010 Nobuyoshi Nakada * vm.c (rb_thread_mark): should mark iseq itself other than normal diff --git a/util.c b/util.c index 368558607f..d42e1662fa 100644 --- a/util.c +++ b/util.c @@ -292,7 +292,10 @@ ruby_add_suffix(VALUE str, const char *suffix) if (*suffix == '.') { /* Style 1 */ if (ext) { - if (strEQ(ext, suffix)) goto fallback; + if (strEQ(ext, suffix)) { + extlen = sizeof(suffix1) - 1; /* suffix2 must be same length */ + suffix = strEQ(suffix, suffix1) ? suffix2 : suffix1; + } slen = ext - name; } rb_str_resize(str, slen); @@ -332,9 +335,9 @@ ruby_add_suffix(VALUE str, const char *suffix) fallback: (void)memcpy(p, !ext || strEQ(ext, suffix1) ? suffix2 : suffix1, 5); } + rb_str_resize(str, strlen(buf)); + memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str)); } - rb_str_resize(str, strlen(buf)); - memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str)); } static int -- cgit v1.2.3