diff --git a/lib/vsnprintf.c b/lib/vsnprintf.c
index 2f572dff984d92bbbda862cf44cda2809d3c3b08..5f38a3d6679ef1d2a6ce25b5c353474f2347c4d4 100644
--- a/lib/vsnprintf.c
+++ b/lib/vsnprintf.c
@@ -555,7 +555,7 @@ static size_t render_xlong_to_ascii(bool usign, long value, char *str,
 		}
 	}
 
-	while (value && (n < STACK_BUF_SIZE)) {
+	do {
 
 		digit = (char) (value % spec->base);
 
@@ -572,7 +572,7 @@ static size_t render_xlong_to_ascii(bool usign, long value, char *str,
 
 		n++;
 		value /= spec->base;
-	}
+	} while (value && (n < STACK_BUF_SIZE));
 
 	return render_final(str, end, sign, buf, n, spec);
 }