summaryrefslogtreecommitdiff
path: root/gl/printf-args.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-06-07 13:13:51 +0000
committerSimon Josefsson <simon@josefsson.org>2006-06-07 13:13:51 +0000
commit9ede4ef442d26f5ca96bfceaffa2a8029b5dddf0 (patch)
tree6bd470cd1efe654a6513fd117e572af77ba276cf /gl/printf-args.c
parent73a39267eefd2d3cdd2b2ee623d937471e52b0aa (diff)
downloadgnutls-9ede4ef442d26f5ca96bfceaffa2a8029b5dddf0.tar.gz
Update.
Diffstat (limited to 'gl/printf-args.c')
-rw-r--r--gl/printf-args.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/gl/printf-args.c b/gl/printf-args.c
index ba4b8b31fe..67abdc3f81 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -84,10 +84,29 @@ printf_fetchargs (va_list args, arguments *a)
#endif
case TYPE_STRING:
ap->a.a_string = va_arg (args, const char *);
+ /* A null pointer is an invalid argument for "%s", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_string == NULL)
+ ap->a.a_string = "(NULL)";
break;
#ifdef HAVE_WCHAR_T
case TYPE_WIDE_STRING:
ap->a.a_wide_string = va_arg (args, const wchar_t *);
+ /* A null pointer is an invalid argument for "%ls", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_wide_string == NULL)
+ {
+ static const wchar_t wide_null_string[] =
+ {
+ (wchar_t)'(',
+ (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
+ (wchar_t)')',
+ (wchar_t)0
+ };
+ ap->a.a_wide_string = wide_null_string;
+ }
break;
#endif
case TYPE_POINTER: