diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-01 15:44:38 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-01 15:44:38 +0000 |
commit | 2f0e3675761d7cd589bc6d43d3a6cd73fa89f0a1 (patch) | |
tree | 1220e8d22a520be3dd50bee262471627f245d66a | |
parent | b22c83311d62dbb74677418c010f20c12e64faf2 (diff) |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | util.c | 9 |
2 files changed, 11 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Mon Aug 2 00:03:18 2010 Yusuke Endoh <mame@tsg.ne.jp> + + * 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 <nobu@ruby-lang.org> * vm.c (rb_thread_mark): should mark iseq itself other than normal @@ -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 |