]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix xitoa()
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 8 Sep 2019 08:35:02 +0000 (14:05 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 8 Sep 2019 08:35:02 +0000 (14:05 +0530)
src/nnn.c

index 01565dc592ea2e3a20054dd4b29bca3d0f6945c0..1631348be7392ec2d9232c704d306afc3842e5d9 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -536,9 +536,12 @@ static uint xatoi(const char *str)
 static char *xitoa(uint val)
 {
        static char ascbuf[32] = {0};
-       int i;
+       int i = 30;
 
-       for (i = 30; val && i; --i, val /= 10)
+       if (!val)
+               return "0";
+
+       for (; val && i; --i, val /= 10)
                ascbuf[i] = '0' + (val % 10);
 
        return &ascbuf[++i];