summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-05 07:50:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-05 07:50:50 +0000
commit6ad91c11efc5f43442e9ca4d13b4de22c0746166 (patch)
tree40230b127cc5a097b5f9a62be55d79342b845da8
parentd547985d5b0e960af0299d9a5b12d4e008f90631 (diff)
downloadruby-6ad91c11efc5f43442e9ca4d13b4de22c0746166.tar.gz
ruby-6ad91c11efc5f43442e9ca4d13b4de22c0746166.tar.xz
ruby-6ad91c11efc5f43442e9ca4d13b4de22c0746166.zip
* string.c (rb_str_resize): copy if old data is not empty
[ruby-core:14785] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--string.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e8c99eea3..93118875c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
-Sat Jan 5 14:45:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jan 5 16:50:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_resize): copy at old length but not new length.
+ * string.c (rb_str_resize): copy if old data is not empty
[ruby-core:14785]
Sat Jan 5 13:04:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
diff --git a/string.c b/string.c
index 979eb9bf8..ccebadb29 100644
--- a/string.c
+++ b/string.c
@@ -948,7 +948,7 @@ rb_str_resize(VALUE str, long len)
else if (len <= RSTRING_EMBED_LEN_MAX) {
char *ptr = RSTRING(str)->as.heap.ptr;
STR_SET_EMBED(str);
- if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, slen);
+ if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, len);
RSTRING(str)->as.ary[len] = '\0';
STR_SET_EMBED_LEN(str, len);
xfree(ptr);