From 8e31681c5a5a2fd6bbdf751bcc900a4481e2fa29 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 29 Dec 2015 05:22:46 -0700 Subject: tiny-printf: Avoid printing NULL strings Add a check for NULL strings to avoid printing junk to the console. Signed-off-by: Simon Glass Reviewed-by: Stefan Roese --- lib/tiny-printf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 403b134cd1..efe5c25a59 100644 --- a/lib/tiny-printf.c +++ b/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); + } } } -- cgit v1.2.1