]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix build failure on linux made by commit b3296a25e1 to be able to compile
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 17 Sep 2012 11:21:13 +0000 (20:21 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 17 Sep 2012 11:21:13 +0000 (20:21 +0900)
the source file without warnings on gcc and clang.

tar/util.c

index 70788aee1da299675cd6afabfc19bb7f88fcd8e8..92b2804ae59de999d2e5e5037e141f9c4baef5cc 100644 (file)
@@ -148,7 +148,13 @@ safe_fprintf(FILE *f, const char *fmt, ...)
 
        /* Note: mbrtowc() has a cleaner API, but mbtowc() seems a bit
         * more portable, so we use that here instead. */
-       (void)mbtowc(NULL, NULL, 1); /* Reset the shift state. */
+       if (mbtowc(NULL, NULL, 1) == -1) { /* Reset the shift state. */
+               /* NOTE: This case may not happen, but it needs to be compiled
+                * safely without warnings by both gcc on linux and clang. */
+               if (fmtbuff_heap != NULL)
+                       free(fmtbuff_heap);
+               return;
+       }
 
        /* Write data, expanding unprintable characters. */
        p = fmtbuff;