summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-08-21 10:18:43 +0200
committerWerner Koch <wk@gnupg.org>2002-08-21 10:18:43 +0200
commitbc8364ec4f1ac644eef0b2126cc8822cfbec667f (patch)
treebd131d0260d846755a5e86928d29db7c47856468 /common
parent* divert-scd.c (getpin_cb): Pass a more descritive text to the (diff)
downloadgnupg2-bc8364ec4f1ac644eef0b2126cc8822cfbec667f.tar.xz
gnupg2-bc8364ec4f1ac644eef0b2126cc8822cfbec667f.zip
* vasprintf.c: Hack to handle NULL for %s.
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog4
-rw-r--r--common/vasprintf.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index e1f2e79b7..2797c1140 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,7 @@
+2002-08-20 Werner Koch <wk@gnupg.org>
+
+ * vasprintf.c: Hack to handle NULL for %s.
+
2002-08-09 Werner Koch <wk@gnupg.org>
* signal.c: New. Taken from GnuPG 1.1.91.
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':