]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tiny-printf: Avoid printing NULL strings
authorSimon Glass <sjg@chromium.org>
Tue, 29 Dec 2015 12:22:46 +0000 (05:22 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 21 Jan 2016 02:06:22 +0000 (19:06 -0700)
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>
lib/tiny-printf.c

index 403b134cd11222c493df68ab027cb085124ae681..efe5c25a59381f1f58f01c65818cb67fdf5a7b00 100644 (file)
@@ -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);
+                       }
                }
        }