diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-16 02:44:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-16 02:44:04 +0000 |
commit | 57a16887438de18f2bfa71b0dba87a4a01f40a35 (patch) | |
tree | 064da9a4524739c1232f889d1e557cc142f296e0 /sprintf.c | |
parent | 279086dd618bf34892e250b509630d721d0bd0a4 (diff) |
sprintf.c: integer overflow
* sprintf.c (rb_str_format): fix a possible integer overflow and
suppress implicit conversion warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1026,8 +1026,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) { VALUE val = GETARG(), num, den; int sign = (flags&FPLUS) ? 1 : 0, zero = 0; - long len; - int i, done = 0, prefix = 0; + long len, done = 0; + int prefix = 0; if (!RB_TYPE_P(val, T_RATIONAL)) { nextvalue = val; goto float_value; @@ -1100,7 +1100,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) } if ((flags & FWIDTH) && width > done) { if (!(flags&FMINUS)) { - int shifting = (flags&FZERO) ? done - prefix : done; + long i, shifting = (flags&FZERO) ? done - prefix : done; for (i = 1; i <= shifting; i++) buf[width - i] = buf[done - i]; blen -= shifting; |