From 5c250a10332dc17263c66deb629b5fa8c4320f8a Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 8 Feb 2004 09:53:50 +0000 Subject: [PATCH] corrections for buffers git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/strconv.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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); -- 2.47.2