mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
279086dd61
commit
57a1688743
1 changed files with 3 additions and 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;
|
||||
|
|
Loading…
Reference in a new issue