Forráskód Böngészése

tiny-printf: Avoid printing NULL strings

Add a check for NULL strings to avoid printing junk to the console.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Simon Glass 9 éve
szülő
commit
8e31681c5a
1 módosított fájl, 4 hozzáadás és 2 törlés
  1. 4 2
      lib/tiny-printf.c

+ 4 - 2
lib/tiny-printf.c

@@ -108,8 +108,10 @@ int vprintf(const char *fmt, va_list va)
 				w--;
 			while (w-- > 0)
 				putc(lz ? '0' : ' ');
-			while ((ch = *p++))
-				putc(ch);
+			if (p) {
+				while ((ch = *p++))
+					putc(ch);
+			}
 		}
 	}