diff options
author | Elliott Hughes <enh@google.com> | 2020-12-15 14:01:30 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-12-18 07:00:36 -0600 |
commit | 2eacf3843380344ea7cfdbf49167ed0d293430a1 (patch) | |
tree | 344ade973af2559432b0c3e3bebadf45ea7b07ca /toys | |
parent | b74d4319dcbf173e596bc422796058091e7e07b8 (diff) | |
download | toybox-2eacf3843380344ea7cfdbf49167ed0d293430a1.tar.gz |
seq.c: fix itoa for INT_MIN in case itoa gets used elsewhere.
It can't actually be used for INT_MIN in the current context because the
`dd += increment` on line 100 means that even if "last" is INT_MIN, we
won't take the fast path because INT_MIN - 1 isn't representable.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/lsb/seq.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/toys/lsb/seq.c b/toys/lsb/seq.c index 45c82d51..fccccd8f 100644 --- a/toys/lsb/seq.c +++ b/toys/lsb/seq.c @@ -56,12 +56,13 @@ static double parsef(char *s) char *itoa(char *s, int i) { char buf[16], *ff = buf; + unsigned n = i; if (i<0) { *s++ = '-'; - i = -i; + n = -i; } - do *ff++ = '0'+i%10; while ((i /= 10)); + do *ff++ = '0'+n%10; while ((n /= 10)); do *s++ = *--ff; while (ff>buf); *s++ = '\n'; |