summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-16 02:44:04 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-16 02:44:04 (GMT)
commit57a16887438de18f2bfa71b0dba87a4a01f40a35 (patch)
tree064da9a4524739c1232f889d1e557cc142f296e0 /sprintf.c
parent279086dd618bf34892e250b509630d721d0bd0a4 (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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sprintf.c b/sprintf.c
index b73aabd..85adc21 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -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;