diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 4 |
1 files changed, 4 insertions, 0 deletions
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; } |