diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-05 07:50:50 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-05 07:50:50 +0000 |
commit | 76c2550b5b39f96875205b4dc7fe226c0905c3d4 (patch) | |
tree | 40230b127cc5a097b5f9a62be55d79342b845da8 /string.c | |
parent | 80de7a2fe197408285c7a1a7ac5e466451a05b87 (diff) | |
download | ruby-76c2550b5b39f96875205b4dc7fe226c0905c3d4.tar.gz |
* string.c (rb_str_resize): copy if old data is not empty
[ruby-core:14785]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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); |