diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-07-09 11:18:28 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-07-09 11:28:19 (GMT) |
commit | cae93bf07958ea065f4fefd729099bac59a1bf14 (patch) | |
tree | d4506cf7a33f6e3ed285d72b9ad1f3e525045a2f /src/corelib/codecs | |
parent | ed564a3fef39b649bd38a181126711431f0b40ab (diff) | |
download | Qt-cae93bf07958ea065f4fefd729099bac59a1bf14.zip Qt-cae93bf07958ea065f4fefd729099bac59a1bf14.tar.gz Qt-cae93bf07958ea065f4fefd729099bac59a1bf14.tar.bz2 |
Fixes a memory corruption when converting data with QIconvCodec
This partially reverts 9a5b40a011bd1b15a67d83564af55011761f8ad9 for
the QIconvCodec.
Reviewed-by: hjk
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r-- | src/corelib/codecs/qiconvcodec.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 1bf76ea..188ac8c 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -225,10 +225,11 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState char *inBytes = const_cast<char *>(chars); #endif + QByteArray in; if (remainingCount) { // we have to prepend the remaining bytes from the previous conversion inBytesLeft += remainingCount; - QByteArray in(inBytesLeft, Qt::Uninitialized); + in.resize(inBytesLeft); inBytes = in.data(); memcpy(in.data(), remainingBuffer, remainingCount); @@ -362,9 +363,10 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt inBytes = const_cast<char *>(reinterpret_cast<const char *>(uc)); inBytesLeft = len * sizeof(QChar); + QByteArray in; if (convState && convState->remainingChars) { // we have one surrogate char to be prepended - QByteArray in(sizeof(QChar) + len, Qt::Uninitialized); + in.resize(sizeof(QChar) + len); inBytes = in.data(); QChar remaining = convState->state_data[0]; |