diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-17 18:04:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-17 18:04:30 +0000 |
commit | 0854193a684acc2b3a13ab28091a4397000c8822 (patch) | |
tree | ee0c82d00553324c4e5aff580ed996c7773eb98b /sprintf.c | |
parent | e03c771d1c719b4e4befa8056b66feb42ded4d7c (diff) | |
download | ruby-0854193a684acc2b3a13ab28091a4397000c8822.tar.gz |
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/trunk@57108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -705,10 +705,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; |