diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-12 02:12:19 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-12 02:12:19 +0000 |
commit | f13d10a0afeec1c6e66b4717fd9f12faeda515ff (patch) | |
tree | 0f2e7547e33d71e31645d40905ee3578c50c6295 /io.c | |
parent | eec252e2e520ed1297df6ca8deb089f29e384e2c (diff) | |
download | ruby-f13d10a0afeec1c6e66b4717fd9f12faeda515ff.tar.gz |
* io.c (setup_narg): fix off by one bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -7959,13 +7959,12 @@ setup_narg(int cmd, VALUE *argp, int io_p) len = 256; rb_str_modify(arg); - if (len <= RSTRING_LEN(arg)) { - len = RSTRING_LEN(arg); - } - if (RSTRING_LEN(arg) < len) { + /* expand for data + sentinel. */ + if (RSTRING_LEN(arg) < len+1) { rb_str_resize(arg, len+1); } - RSTRING_PTR(arg)[len] = 17; /* a little sanity check here */ + /* a little sanity check here */ + RSTRING_PTR(arg)[RSTRING_LEN(arg) - 1] = 17; narg = (long)(SIGNED_VALUE)RSTRING_PTR(arg); } } |