summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-01 15:44:38 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-01 15:44:38 +0000
commit2f0e3675761d7cd589bc6d43d3a6cd73fa89f0a1 (patch)
tree1220e8d22a520be3dd50bee262471627f245d66a /util.c
parentb22c83311d62dbb74677418c010f20c12e64faf2 (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
Diffstat (limited to 'util.c')
-rw-r--r--util.c9
1 files changed, 6 insertions, 3 deletions
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