aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-12-15 14:01:30 -0800
committerRob Landley <rob@landley.net>2020-12-18 07:00:36 -0600
commit2eacf3843380344ea7cfdbf49167ed0d293430a1 (patch)
tree344ade973af2559432b0c3e3bebadf45ea7b07ca /toys/lsb
parentb74d4319dcbf173e596bc422796058091e7e07b8 (diff)
downloadtoybox-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/lsb')
-rw-r--r--toys/lsb/seq.c5
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';