* vasprintf.c: Hack to handle NULL for %s.

This commit is contained in:
Werner Koch 2002-08-21 08:18:43 +00:00
parent a71981bace
commit bc8364ec4f
2 changed files with 13 additions and 2 deletions

View File

@ -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.

View File

@ -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':