From 729249159e34d20c8c9bf7529ef645fa8ca9de79 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 2 Feb 2005 14:53:36 +0000 Subject: * ext/stringio/stringio.c (strio_truncate): should MEMZERO an extended part. [ruby-dev:25618] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/stringio/stringio.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ext') diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index b31f1818b2..de96121367 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -934,10 +934,14 @@ strio_truncate(self, len) { VALUE string = writable(StringIO(self))->string; long l = NUM2LONG(len); + long plen = RSTRING(string)->len; if (l < 0) { error_inval("negative legnth"); } rb_str_resize(string, l); + if (plen < l) { + MEMZERO(RSTRING(string)->ptr + plen, char, l - plen); + } return len; } -- cgit v1.2.3