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

View File

@ -247,7 +247,17 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
static int static int
kvprintf(char const *fmt, kvprintf_fn_t *func, void *arg, int radix, va_list ap) 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 nbuf[MAXNBUF];
char *d; char *d;
const char *p, *percent, *q; const char *p, *percent, *q;