summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-13 14:59:08 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-13 14:59:08 (GMT)
commita41d569e6677304712474810cdfb1fd9b3a02311 (patch)
tree6aad12f09713f9896ad2a2334f46ed2ffb8782cb /sprintf.c
parentbd17e255889f35d0ae56e5a4d8a375310adb9ee3 (diff)
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
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sprintf.c b/sprintf.c
index 40872c0..117c568 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -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);