diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-11-16 17:39:32 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-05-30 12:51:37 +0900 |
commit | bb6357cddd5af2c244348e96388a10f7cc6f25b4 (patch) | |
tree | 85b5402fc117ad5e782b6acf47b39beded68d64c /ext | |
parent | 11793f897ce40e833d69d5cd76c13e08a611bcd9 (diff) |
[ruby/stringio] Fix expanding size at ungetc/ungetbyte
https://github.com/ruby/stringio/commit/a35268a3ac
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 3f37c7c66d..f452bd0da0 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -984,7 +984,7 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl) len = RSTRING_LEN(str); rest = pos - len; if (cl > pos) { - long ex = (rest < 0 ? cl-pos : cl+rest); + long ex = cl - (rest < 0 ? pos : len); rb_str_modify_expand(str, ex); rb_str_set_len(str, len + ex); s = RSTRING_PTR(str); |