diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 55e80d90f23..402cb2245ff 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -775,6 +775,9 @@ nextch2: strvalue = argvalues[fmtpos].cptr; else strvalue = va_arg(args, char *); + /* If string is NULL, silently substitute "(null)" */ + if (strvalue == NULL) + strvalue = "(null)"; fmtstr(strvalue, leftjust, fieldwidth, precision, pointflag, target); break;