]> wimlib.net Git - wimlib/blobdiff - src/util.c
wimlib_vfprintf(): Handle %W with null pointer
[wimlib] / src / util.c
index a93e688bee9ebbcf5931a50a6d467e0da48d29f7..5463c83af45748c07271ee50ec6c015e7d8f52ca 100644 (file)
@@ -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)