From 99d96a89ce57edc4de2ff1acb1d4ed7737144140 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 4 Aug 2010 07:09:47 +0000 Subject: * string.c (rb_str_resize): should copy the content properly. a patch from Jeremy Evans at [ruby-core:31615]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index ae88db3761..6d8b606c11 100644 --- a/string.c +++ b/string.c @@ -1723,7 +1723,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, len); + if (len > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, len); RSTRING(str)->as.ary[len] = '\0'; STR_SET_EMBED_LEN(str, len); if (independent) xfree(ptr); -- cgit v1.2.3