summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-16 18:40:22 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-16 18:40:22 +0000
commit2e4b5a32f27d46494198c8e1f62da2c5abb9c883 (patch)
treeab2d312d36e3a6ad12e2cc4512466b1600ae6f57 /sprintf.c
parentf9664eb3c797e4c6ec4061f74996dfac737d407f (diff)
merge revision(s) 57108: [Backport #13121]
sprintf.c: fix width underflow * sprintf.c (rb_str_format): fix memory corruption by width underflow. https://github.com/mruby/mruby/issues/3347 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@57340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index b022c5decc..6c49fe07b6 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -697,10 +697,10 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
CHECK(n);
rb_enc_mbcput(c, &buf[blen], enc);
blen += n;
- FILL(' ', width-1);
+ if (width > 1) FILL(' ', width-1);
}
else {
- FILL(' ', width-1);
+ if (width > 1) FILL(' ', width-1);
CHECK(n);
rb_enc_mbcput(c, &buf[blen], enc);
blen += n;