summaryrefslogtreecommitdiffstats
path: root/ext/stringio
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-02 14:53:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-02 14:53:36 +0000
commit49ace175df6ede06edfa4e4bcbb37b2060f0b032 (patch)
tree8e63277e52eb46c10c83ca2406afae139c26f3a5 /ext/stringio
parent1ebb10f7c72382532b6c151e8af13cf1a4da59d1 (diff)
downloadruby-49ace175df6ede06edfa4e4bcbb37b2060f0b032.tar.gz
ruby-49ace175df6ede06edfa4e4bcbb37b2060f0b032.tar.xz
ruby-49ace175df6ede06edfa4e4bcbb37b2060f0b032.zip
* ext/stringio/stringio.c (strio_truncate): should MEMZERO an extended
part. [ruby-dev:25618] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 7c1e4ba5f..23ba3dce4 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -950,10 +950,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;
}