From d262120348ab685e9f3033f2847953074dc214f2 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Tue, 21 May 2013 23:39:47 +0900 Subject: [PATCH] Fix for reporting unexpected compare results when comparing folders with Ignore Case option. close #20 (failed to convert file contents to utf-8 because of a buffer shortage) --- Src/Common/multiformatText.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/Common/multiformatText.cpp b/Src/Common/multiformatText.cpp index 5ba1084c9..aacfb35df 100644 --- a/Src/Common/multiformatText.cpp +++ b/Src/Common/multiformatText.cpp @@ -623,13 +623,14 @@ bool AnyCodepageToUTF8(int codepage, const String& filepath, const String& filep size_t srcbytes = findNextLine(unicoding, pszBuf + pos + minbufsize, pszBuf + nBufSize) - (pszBuf + pos); if (srcbytes == 0) break; - if (srcbytes > obuf.size()) - obuf.resize(srcbytes * 2, false); + if (srcbytes * 3 > obuf.size()) + obuf.resize(srcbytes * 3 * 2, false); size_t destbytes = obuf.size(); if (pexconv) { size_t srcbytes2 = srcbytes; - pexconv->convert(codepage, CP_UTF8, (const unsigned char *)pszBuf+pos, &srcbytes2, (unsigned char *)obuf.begin(), &destbytes); + if (!pexconv->convert(codepage, CP_UTF8, (const unsigned char *)pszBuf+pos, &srcbytes2, (unsigned char *)obuf.begin(), &destbytes)) + throw "failed to convert file contents to utf-8"; } else { -- 2.11.0