From: Stefan Csomor Date: Sun, 8 Feb 2004 09:53:50 +0000 (+0000) Subject: corrections for buffers X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5c250a10332dc17263c66deb629b5fa8c4320f8a?ds=inline corrections for buffers git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- 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);