diff --git a/lib/vsnprintf.c b/lib/vsnprintf.c
index 695a81c28c7c830b333803935b77b444e33e01ae..5bfe4adbd153be73a1da50cf40edb420129a94d6 100644
--- a/lib/vsnprintf.c
+++ b/lib/vsnprintf.c
@@ -1290,7 +1290,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap)
 
 		/* have we arrived at the end? */
 		if (!(*format))
-		    break;
+			break;
 
 		/* we have encountered a format specifier, try to evaluate it */
 		format++;
@@ -1310,7 +1310,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap)
 	if (size) {
 		if (str) {
 			if (buf < end)
-				buf[0]  = '\0';
+				buf[-1] = '\0';
 			else
 				end[-1] = '\0';
 		}