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(-)
From 11eb542c6b3c8ee8bccd95c3d1ddd8baadb9d409 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Tue, 15 Dec 2020 14:01:30 -0800
Subject: [PATCH] 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(-)
diff --git a/toys/lsb/seq.c b/toys/lsb/seq.c
index 83abc472..beeaed3f 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';
--
2.29.2.684.gfbc64c5ab5-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net