From d547985d5b0e960af0299d9a5b12d4e008f90631 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Jan 2008 05:45:40 +0000 Subject: * string.c (rb_str_resize): copy at old length but not new length. [ruby-core:14785] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6867eab7c..e8c99eea3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jan 5 14:45:38 2008 Nobuyoshi Nakada + + * 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 * ruby.c (proc_options): no need for intermediate object. diff --git a/string.c b/string.c index dfd2de0b4..979eb9bf8 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); - 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); -- cgit