diff options
author | Werner Koch <[email protected]> | 2002-08-21 08:18:43 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2002-08-21 08:18:43 +0000 |
commit | bc8364ec4f1ac644eef0b2126cc8822cfbec667f (patch) | |
tree | bd131d0260d846755a5e86928d29db7c47856468 /common/vasprintf.c | |
parent | * divert-scd.c (getpin_cb): Pass a more descritive text to the (diff) | |
download | gnupg-bc8364ec4f1ac644eef0b2126cc8822cfbec667f.tar.gz gnupg-bc8364ec4f1ac644eef0b2126cc8822cfbec667f.zip |
* vasprintf.c: Hack to handle NULL for %s.
Diffstat (limited to 'common/vasprintf.c')
-rw-r--r-- | common/vasprintf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/common/vasprintf.c b/common/vasprintf.c index dbef4eb08..36121d8cc 100644 --- a/common/vasprintf.c +++ b/common/vasprintf.c @@ -68,7 +68,8 @@ vasprintf (char **result, const char *format, va_list *args) } while (strchr ("hlL", *p)) ++p; - /* Should be big enough for any format specifier except %s and floats. */ + /* Should be big enough for any format specifier except %s + and floats. */ total_width += 30; switch (*p) { @@ -92,7 +93,13 @@ vasprintf (char **result, const char *format, va_list *args) total_width += 307; break; case 's': - total_width += strlen (va_arg (ap, char *)); + { + char *tmp = va_arg (ap, char *); + if (tmp) + total_width += strlen (tmp); + else /* in case the vsprintf does prints a text */ + total_width += 25; /* e.g. "(null pointer reference)" */ + } break; case 'p': case 'n': |