]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Use of archive_strcat() in archive_string_append_from_wcs_to_mbs() is slightly ineffi...
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 8 Apr 2011 08:59:20 +0000 (04:59 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 8 Apr 2011 08:59:20 +0000 (04:59 -0400)
We can trust a contents of buffer, so we should use archive_string_append() instead.

SVN-Revision: 3181

libarchive/archive_string.c

index 672337596b13bbbc95b18421a82ea5d0b1ae2d27..3e433ff5d3888d2d35c30da65e688d99b0a4b43b 100644 (file)
@@ -491,8 +491,7 @@ archive_string_append_from_wcs_to_mbs(struct archive *a,
                /* Flush the buffer when we have <=16 bytes free. */
                /* (No encoding has a single character >16 bytes.) */
                if ((size_t)(p - buff) >= (size_t)(sizeof(buff) - MB_CUR_MAX)) {
-                       *p = '\0';
-                       archive_strcat(as, buff);
+                       archive_string_append(as, buff, p - buff);
                        p = buff;
                }
 #if HAVE_WCRTOMB
@@ -504,8 +503,7 @@ archive_string_append_from_wcs_to_mbs(struct archive *a,
                        return (-1);
                p += n;
        }
-       *p = '\0';
-       archive_strcat(as, buff);
+       archive_string_append(as, buff, p - buff);
        return (0);
 }