diff options
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -113,10 +113,11 @@ sign_bits(base, p) t = p++; \ n = 0; \ for (; p < end && ISDIGIT(*p); p++) { \ - if ((n*10) / 10 != n) { \ + int next_n = 10 * n + (*p - '0'); \ + if (next_n / 10 != n) {\ rb_raise(rb_eArgError, #val " too big"); \ } \ - n = 10 * n + (*p - '0'); \ + n = next_n; \ } \ if (p >= end) { \ rb_raise(rb_eArgError, "malformed format string - %%*[0-9]"); \ @@ -312,7 +313,8 @@ rb_f_sprintf(argc, argv) case '5': case '6': case '7': case '8': case '9': n = 0; for (; p < end && ISDIGIT(*p); p++) { - if ((n*10) / 10 != n) { + int next_n = 10 * n + (*p - '0'); + if (next_n / 10 != n) { rb_raise(rb_eArgError, "width too big"); } n = 10 * n + (*p - '0'); |