handle printf("%s", NULL) without crashing

This commit is contained in:
Kevin Lange 2014-04-13 02:04:34 -07:00
parent 20a1c56023
commit 7d2083cae9

View File

@ -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++;
}