handle printf("%s", NULL) without crashing
This commit is contained in:
parent
20a1c56023
commit
7d2083cae9
@ -94,6 +94,9 @@ vasprintf(char * buf, const char *fmt, va_list args) {
|
||||
switch (fmt[i]) {
|
||||
case 's': /* String pointer -> String */
|
||||
s = (char *)va_arg(args, char *);
|
||||
if (s == NULL) {
|
||||
s = "(null)";
|
||||
}
|
||||
while (*s) {
|
||||
buf[ptr++] = *s++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user