diff -Naur qt-x11-free-3.3.8b-orig/src/codecs/qbig5codec.cpp qt-x11-free-3.3.8b/src/codecs/qbig5codec.cpp --- qt-x11-free-3.3.8b-orig/src/codecs/qbig5codec.cpp 2008-01-15 22:09:13.000000000 +0300 +++ qt-x11-free-3.3.8b/src/codecs/qbig5codec.cpp 2008-08-17 09:36:19.000000000 +0400 @@ -556,6 +556,11 @@ { //qDebug("QBig5Decoder::toUnicode(const char* chars = \"%s\", int len = %d)", chars, len); QString result; + if (!chars) return QString::null; + if (chars && (chars[0]=='\0' || len==0)) { + result.setLength(0); + return result; + } for (int i=0; itoUnicode(chars,len); delete i; @@ -1477,6 +1489,13 @@ QString toUnicode(const char* chars, int len) const { + if ( !chars ) return QString::null; + if ( chars && (chars[0]=='\0' || len==0) ) { + QString blank; + blank.setLength(0); + return blank; + } + const uchar* uchars = (const uchar*)chars; QString result; QMultiByteUnicodeTable* multiByte=to_unicode_multiByte; @@ -1549,6 +1568,13 @@ QString QTextCodecFromIODDecoder::toUnicode(const char* chars, int len) { + if ( !chars ) return QString::null; + if ( chars && (chars[0]=='\0' || len==0) ) { + QString blank; + blank.setLength(0); + return blank; + } + const uchar* uchars = (const uchar*)chars; QString result; while (len--) { @@ -2319,13 +2345,17 @@ QString QSimpleTextCodec::toUnicode(const char* chars, int len) const { - if ( len <= 0 || chars == 0 ) - return QString::null; + if ( !chars ) return QString::null; + if ( chars && (chars[0]=='\0' || len==0) ) { + QString blank; + blank.setLength(0); + return blank; + } const unsigned char * c = (const unsigned char *)chars; int i; - for ( i = 0; i < len; i++ ) + for ( i = 0; i < len || len < 0; i++ ) if ( c[i] == '\0' ) { len = i; break; @@ -2515,10 +2545,29 @@ QString QLatin1Codec::toUnicode(const char* chars, int len) const { - if ( chars == 0 ) - return QString::null; + if ( !chars ) return QString::null; + if ( chars && (chars[0]=='\0' || len==0) ) { + QString blank; + blank.setLength(0); + return blank; + } + + QString r; + + const unsigned char * c = (const unsigned char *)chars; + int i; + + for ( i = 0; i < len; i++ ) + if ( c[i] == '\0' ) len = i; - return QString::fromLatin1(chars, len); + if( len > 0 ) { + r.setUnicode(0, len); + QChar* uc = (QChar*)r.unicode(); // const_cast + + for ( i = 0; i < len; i++ ) + uc[i] = QChar( c[i], 0 ); + } + return r; } diff -Naur qt-x11-free-3.3.8b-orig/src/codecs/qutfcodec.cpp qt-x11-free-3.3.8b/src/codecs/qutfcodec.cpp --- qt-x11-free-3.3.8d/src/codecs/qutfcodec.cpp~ 2011-11-16 18:51:21.000000000 +0400 +++ qt-x11-free-3.3.8d/src/codecs/qutfcodec.cpp 2011-11-16 18:54:06.000000000 +0400 @@ -303,6 +303,16 @@ public: QString toUnicode(const char* chars, int len) { QString result; + if (!chars) return QString::null; + if (chars && (chars[0]=='\0' || len==0)) { + result.setLength(0); + return result; + } + if (!chars) return QString::null; + if (chars && (chars[0]=='\0' || len==0)) { + result.setLength(0); + return result; + } result.setLength( len + 1 ); // worst case QChar *qch = (QChar *)result.unicode(); QChar ch;