X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8057c6d68f922ca0ae697d29f8c94f1d935e0421..afb21636a4e4ab7c20906e89e20372bc1ac5b47b:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index ea5e74110f..6363e4001c 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1232,15 +1232,15 @@ public: OSStatus status = noErr ; ByteCount byteOutLen ; ByteCount byteInLen = strlen(psz) ; - ByteCount byteBufferLen = n ; wchar_t *tbuf = NULL ; if (buf == NULL) { - n = byteInLen * SIZEOF_WCHAR_T ; - tbuf = (wchar_t*) malloc( n ) ; + n = byteInLen ; + tbuf = (wchar_t*) malloc( n * SIZEOF_WCHAR_T) ; } + ByteCount byteBufferLen = n * SIZEOF_WCHAR_T ; status = TECConvertText(m_MB2WC_converter, (ConstTextPtr) psz , byteInLen, &byteInLen, (TextPtr) (buf ? buf : tbuf) , byteBufferLen, &byteOutLen); @@ -1259,16 +1259,17 @@ public: OSStatus status = noErr ; ByteCount byteOutLen ; ByteCount byteInLen = wxWcslen(psz) * SIZEOF_WCHAR_T ; - ByteCount byteBufferLen = n ; char *tbuf = NULL ; if (buf == NULL) { - n = byteInLen ; + // worst case + n = byteInLen * 2 ; tbuf = (char*) malloc( n ) ; } + ByteCount byteBufferLen = n ; status = TECConvertText(m_WC2MB_converter, (ConstTextPtr) psz , byteInLen, &byteInLen, (TextPtr) ( buf ? buf : tbuf ) , byteBufferLen, &byteOutLen);