diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-05 05:45:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-05 05:45:40 +0000 |
commit | 80de7a2fe197408285c7a1a7ac5e466451a05b87 (patch) | |
tree | 553f999443bed1b327401db5520113b63993fd3f | |
parent | 4be0eb95cf92f40d68918b8f7f50e7367bff4aec (diff) | |
download | ruby-80de7a2fe197408285c7a1a7ac5e466451a05b87.tar.gz |
* string.c (rb_str_resize): copy at old length but not new length.
[ruby-core:14785]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | string.c | 2 |
2 files changed, 6 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Sat Jan 5 14:45:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * string.c (rb_str_resize): copy at old length but not new length. + [ruby-core:14785] + Sat Jan 5 13:04:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * ruby.c (proc_options): no need for intermediate object. @@ -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); - MEMCPY(RSTRING(str)->as.ary, ptr, char, len); + if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, slen); RSTRING(str)->as.ary[len] = '\0'; STR_SET_EMBED_LEN(str, len); xfree(ptr); |