* 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
This commit is contained in:
parent
eec252e2e5
commit
f13d10a0af
@ -1,3 +1,7 @@
|
|||||||
|
Sat Nov 12 10:59:49 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* io.c (setup_narg): fix off by one bug.
|
||||||
|
|
||||||
Sat Nov 12 10:56:43 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat Nov 12 10:56:43 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* io.c (+setup_narg): factor out length calculation logic.
|
* io.c (+setup_narg): factor out length calculation logic.
|
||||||
|
9
io.c
9
io.c
@ -7959,13 +7959,12 @@ setup_narg(int cmd, VALUE *argp, int io_p)
|
|||||||
len = 256;
|
len = 256;
|
||||||
rb_str_modify(arg);
|
rb_str_modify(arg);
|
||||||
|
|
||||||
if (len <= RSTRING_LEN(arg)) {
|
/* expand for data + sentinel. */
|
||||||
len = RSTRING_LEN(arg);
|
if (RSTRING_LEN(arg) < len+1) {
|
||||||
}
|
|
||||||
if (RSTRING_LEN(arg) < len) {
|
|
||||||
rb_str_resize(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);
|
narg = (long)(SIGNED_VALUE)RSTRING_PTR(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user