From kfm-devel Wed Aug 16 17:33:53 2000 From: David Faure Date: Wed, 16 Aug 2000 17:33:53 +0000 To: kfm-devel Subject: Bug#8266: Non-printable characters lead to infinite loop in QPainter's qt_format_text X-MARC-Message: https://marc.info/?l=kfm-devel&m=96644811217608 Version: 2.2beta1 Severity: critical A file with a non-printable character in its name in a QIconView can lead to an infinite loop in QFontMetrics::boundingRect() (which qiconview calls in word-wrap mode). The illegal chars in the filename can happen this way: * create a file on a Window machine, containing accentuated letters * copy it to a linux machine using smb. -> the file will have illegal chars in the filename The filename appears under ls as "La d?marche qualit? sur les ?tudes.doc" where the '?' is in fact a 'e' with an acute accent, when written under Windows, and for this char, QChar::unicode() returns 130. Tried to debug qt_format_text, which is the one that loops indefinitely, but that stuff is quite hairy ;-) The main loop in qt_format_text loops indefinitely, going to 38 (the end of the string), then back to 28, 29, 30... 38, 28, 29 etc. :) Since breakindex is never set to something else than 0, when it arrives at the end it substracts 10 and starts again. This pseudo patch below fixes the problem for me, but I have no idea if that's the right thing to do at all. if ( tw+cw > w ) { if ( breakindex > 0 ) { breakwithinwords = FALSE; codes[begline] = BEGLINE | QMIN(tw,MAXWIDTH); maxwidth = QMAX(maxwidth,tw); begline = breakindex; tw = cw; breakindex = tabindex = 0; cw = 0; nlines++; - } + } else if ( /* do not add !breakwithinwords &&*/ tw+cw > w && word.length() > 1) { breakwithinwords = TRUE; breakwidth = 0; p -= word.length(); k -= word.length(); index = begline+1; tw = 0; word = ""; continue; } Thanks for looking into this asap. Feel free to ask for some more info or debug output, or for sending a patch for me to test, in case you don't have a windows machine at hand :) -- David FAURE, david@mandrakesoft.com, faure@kde.org http://home.clara.net/faure/, http://www.konqueror.org/ KDE, Making The Future of Computing Available Today See http://www.kde.org/kde1-and-kde2.html for how to set up KDE 2