1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

sprintf.c: fix out-of-bound access

* sprintf.c (rb_str_format): get rid of out-of-bound access when
  single % at the end.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-03-13 14:59:08 +00:00
parent bd17e25588
commit a41d569e66

View file

@ -517,6 +517,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
VALUE sym = Qnil;
for (t = p; t < end && *t != '%'; t++) ;
if (t + 1 == end) ++t;
PUSH(p, t - p);
if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) {
scanned += rb_str_coderange_scan_restartable(buf+scanned, buf+blen, enc, &coderange);