From: Eric Biggers Date: Mon, 22 Apr 2013 22:08:39 +0000 (-0500) Subject: wimlib_vfprintf(): Handle %W with null pointer X-Git-Tag: v1.3.3~51 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=d35d6c92657e89e10971c673f26ce903f6a98eed wimlib_vfprintf(): Handle %W with null pointer --- diff --git a/src/util.c b/src/util.c index a93e688b..5463c83a 100644 --- a/src/util.c +++ b/src/util.c @@ -80,20 +80,25 @@ special: tchar *tstr; size_t tstr_nbytes; utf16lechar *ucs = va_arg(va, utf16lechar*); - size_t ucs_nbytes = utf16le_strlen(ucs); - ret = utf16le_to_tstr(ucs, ucs_nbytes, - &tstr, &tstr_nbytes); - if (ret) { - ret = tfprintf(fp, T("??????")); + if (ucs) { + size_t ucs_nbytes = utf16le_strlen(ucs); + + ret = utf16le_to_tstr(ucs, ucs_nbytes, + &tstr, &tstr_nbytes); + if (ret) { + ret = tfprintf(fp, T("??????")); + } else { + ret = tfprintf(fp, T("%"TS), tstr); + FREE(tstr); + } + if (ret < 0) + return -1; + else + n += ret; } else { - ret = tfprintf(fp, T("%"TS), tstr); - FREE(tstr); + n += tfprintf(fp, T("(null)")); } - if (ret < 0) - return -1; - else - n += ret; p++; } else { if (tputc(*p, fp) == EOF)