summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-08 08:09:28 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-08 08:09:28 +0000
commitaeebb6e53874acbba8b614420076a48b2485b087 (patch)
tree068aed0548776454c4c05736b2d36d3068166ec2 /string.c
parentb62f04f5e10cebb1539667c343e136cc69434233 (diff)
* string.c (rb_str_concat): partially reverts r30040 because
it unpexpectedly changed the behavior of String#<<. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/string.c b/string.c
index bee5fb100b..cdb919939b 100644
--- a/string.c
+++ b/string.c
@@ -1998,14 +1998,23 @@ rb_str_concat(VALUE str1, VALUE str2)
unsigned int lc;
if (FIXNUM_P(str2)) {
+ if ((int)str2 < 0)
+ rb_raise(rb_eRangeError, "negative argument");
lc = FIX2UINT(str2);
}
else if (TYPE(str2) == T_BIGNUM) {
+ if (!RBIGNUM_SIGN(str2))
+ rb_raise(rb_eRangeError, "negative argument");
lc = NUM2UINT(str2);
}
else {
return rb_str_append(str1, str2);
}
+#if SIZEOF_INT < SIZEOF_VALUE
+ if ((VALUE)lc > UINT_MAX) {
+ rb_raise(rb_eRangeError, "%"PRIuVALUE" out of char range", lc);
+ }
+#endif
{
rb_encoding *enc = STR_ENC_GET(str1);
long pos = RSTRING_LEN(str1);