[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    [Bug 88788] New: [TESTCASE] kate crash opening binary file (and
From:       Gregorio Guidi <g.guidi () sns ! it>
Date:       2004-09-03 17:52:16
Message-ID: 20040903195214.88788.g.guidi () sns ! it
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
        
http://bugs.kde.org/show_bug.cgi?id=88788        
           Summary: [TESTCASE] kate crash opening binary file (and possible
                    qt fix?)
           Product: kate
           Version: unspecified
          Platform: Compiled Sources
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: crash
          Priority: NOR
         Component: general
        AssignedTo: kwrite-devel kde org
        ReportedBy: g.guidi sns it


Version:            (using KDE Devel)
Installed from:    Compiled sources

Opening this binary file: (and others)

http://bugs.gentoo.org/attachment.cgi?id=38754&action=view

and setting the encoding to iso8859-15 causes a crash with the
following backtrace:

#5  0x40f73db0 in QLatin15Codec::toUnicode(char const*, int) const ()
   from /usr/qt/3/lib/libqt-mt.so.3
#6  0x40f7153f in QTextStatelessDecoder::toUnicode(char const*, int) ()
   from /usr/qt/3/lib/libqt-mt.so.3
#7  0x41bf5564 in KateFileLoader::readLine() (this=0xbfffd600)
    at katebuffer.cpp:165
#8  0x41bf239b in KateBufBlock::fillBlock(KateFileLoader*) (this=0x81f69c0, 
    stream=0xbfffd600) at katebuffer.cpp:1123
#9  0x41bf2143 in KateBufBlock (this=0x81f69c0, parent=0xffffff5c, prev=0x0, 
    next=0xffffff5c, stream=0xbfffd600) at katebuffer.cpp:1071
#10 0x41bf0042 in KateBuffer::openFile(QString const&) (this=0x81aad10, 
    m_file= 0x81f69c0) at katebuffer.cpp:437


For reference, the QLatin15Codec::toUnicode function is here:

QString QLatin15Codec::toUnicode(const char* chars, int len) const
{
    if ( chars == 0 )
        return QString::null;

    QString str = QString::fromLatin1(chars, len);
    QChar *uc = (QChar *)str.unicode();
    while( len-- ) {
        switch( uc->unicode() ) {
            case 0xa4:
                *uc = 0x20ac;
                break;
	[...]

           case 0xbe:
                *uc = 0x0178;
                break;
            default:
                break;
        }
        uc++;
    }
    return str;
}


Just to know if I get it correctly: kate reads files in chunks and stores them in a \
QString, so it is expected that when the chunk is from a binary file and contains a \
'\0' character, the QString is truncated and large part of the data is lost. (This is \
ok, even if I don't understand why it does happen with QString::fromLatin1
() but not when using QString::fromUtf8() ).
But maybe the following patch (against qt-3.3.2) should be sent to 
Qt to avoid the crash? (tested a bit and seems to work)

--- src/codecs/qtextcodec.cpp.orig      2004-09-03 19:46:26.782326976 +0200
+++ src/codecs/qtextcodec.cpp   2004-09-03 19:46:55.388978104 +0200
 @ -2541,6 +2541,7  @

     QString str = QString::fromLatin1(chars, len);
     QChar *uc = (QChar *)str.unicode();
+    len = str.length();
     while( len-- ) {
        switch( uc->unicode() ) {
            case 0xa4:
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic