summaryrefslogtreecommitdiff
path: root/lib/tiny-printf.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-12-29 12:22:46 (GMT)
committerSimon Glass <sjg@chromium.org>2016-01-21 02:06:22 (GMT)
commit8e31681c5a5a2fd6bbdf751bcc900a4481e2fa29 (patch)
tree342441dd9382f84f8e1fd52c089ba394b378a97f /lib/tiny-printf.c
parent9ab401ae0eb0386e300f24262c3b9178892769aa (diff)
downloadu-boot-8e31681c5a5a2fd6bbdf751bcc900a4481e2fa29.tar.xz
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>
Diffstat (limited to 'lib/tiny-printf.c')
-rw-r--r--lib/tiny-printf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 403b134..efe5c25 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);
+ }
}
}