diff options
author | Mike Frysinger <vapier@gentoo.org> | 2008-11-16 07:15:48 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-11-16 07:15:48 +0000 |
commit | fe6802f063cd147711bb63f8705b710a744ce8c6 (patch) | |
tree | ac9220a3014e2a5e8864136cd13582546766c166 /libsbutil | |
parent | tests: add errp() (diff) | |
download | sandbox-fe6802f063cd147711bb63f8705b710a744ce8c6.tar.gz sandbox-fe6802f063cd147711bb63f8705b710a744ce8c6.tar.bz2 sandbox-fe6802f063cd147711bb63f8705b710a744ce8c6.zip |
sb_printf: handle NULL pointers for %s
if told to printf(%s) a NULL pointer, output "(null)" rather than crash
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r-- | libsbutil/sb_printf.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libsbutil/sb_printf.c b/libsbutil/sb_printf.c index c89eccd..b06d749 100644 --- a/libsbutil/sb_printf.c +++ b/libsbutil/sb_printf.c @@ -86,6 +86,8 @@ void sb_vfdprintf(int fd, const char *format, va_list args) } case 's': { char *s = va_arg(args, char *); + if (!s) + s = "(null)"; size_t len = strlen(s); while (len < padding--) sb_write(fd, " ", 1); |