From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Tue, 29 Dec 2015 14:23:41 +0100 Subject: [U-Boot] [PATCH 04/10] tiny-printf: Avoid printing NULL strings In-Reply-To: <1451391772-6203-5-git-send-email-sjg@chromium.org> References: <1451391772-6203-1-git-send-email-sjg@chromium.org> <1451391772-6203-5-git-send-email-sjg@chromium.org> Message-ID: <5682895D.20709@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 29.12.2015 13:22, Simon Glass wrote: > Add a check for NULL strings to avoid printing junk to the console. > > Signed-off-by: Simon Glass > --- > > lib/tiny-printf.c | 6 ++++-- > 1 file 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); > + } > } > } > > Reviewed-by: Stefan Roese Thanks, Stefan