From: Eric Wong Date: 2017-03-20T23:33:38+00:00 Subject: [ruby-core:80258] Re: [ruby-cvs:65191] nobu:r58021 (trunk): sprintf.c: use FILL --- a/sprintf.c +++ b/sprintf.c @@ -74,6 +74,7 @@ sign_bits(int base, const char *p) } while (0) #define FILL(c, l) do { \ + if ((l) <= 0) break;\ CHECK(l);\ FILL_(c, l);\ } while (0) @@ -758,20 +759,15 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) if ((flags&FWIDTH) && (width > slen)) { width -= (int)slen; if (!(flags&FMINUS)) { - CHECK(width); - while (width--) { - buf[blen++] = ' '; - } + FILL(' ', width); + width = 0; } CHECK(len); memcpy(&buf[blen], RSTRING_PTR(str), len); I'm not familiar with this code; but we need to update blen for memcpy, right? Maybe other callsites will need blen updated, too. Unsubscribe: