From 2eacf3843380344ea7cfdbf49167ed0d293430a1 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 15 Dec 2020 14:01:30 -0800 Subject: 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. --- toys/lsb/seq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys/lsb') 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'; -- cgit v1.2.3