loader: asprinf does crash arm64 due to missing NULL pointer check

PCHAR macro needs to check if d is NULL.

MFC after:	3 days
This commit is contained in:
Toomas Soome 2019-11-01 06:54:07 +00:00
parent f852618602
commit 98e28b71b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354237

View File

@ -247,7 +247,17 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
static int
kvprintf(char const *fmt, kvprintf_fn_t *func, void *arg, int radix, va_list ap)
{
#define PCHAR(c) {int cc=(c); if (func) (*func)(cc, arg); else *d++ = cc; retval++; }
#define PCHAR(c) { \
int cc = (c); \
\
if (func) { \
(*func)(cc, arg); \
} else if (d != NULL) { \
*d++ = cc; \
} \
retval++; \
}
char nbuf[MAXNBUF];
char *d;
const char *p, *percent, *q;