summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-04-17 06:24:48 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-04-17 06:24:48 +0000
commitcf520dda16af27d2ce41b5b082bf4e5035815cb0 (patch)
treeb1e49888c083cf2f93a6c7a72f5ad36448b52b98 /string.c
parent57c75615b9934230e317fd6b84296d514e919a1f (diff)
2000-04-17
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/string.c b/string.c
index 2726f60cec..d74d97f8a8 100644
--- a/string.c
+++ b/string.c
@@ -855,6 +855,10 @@ rb_str_replace(str, beg, len, val)
int beg;
int len;
{
+ if (RSTRING(str)->len < beg + len) {
+ len = RSTRING(str)->len - beg;
+ }
+
if (len < RSTRING(val)->len) {
/* expand string */
REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+RSTRING(val)->len-len+1);