Qt 5.6 behavior change with QByteArray(str, size) and QFile::encodeName()

David Faure faure at kde.org
Sat Nov 7 19:07:11 UTC 2015


KTar's unittests detected a behavior change in Qt.
Thiago, is it intentional, or should it be fixed in Qt ?

KTar does

QString name = QFile::decodeName(QByteArray(buffer, 100));

where buffer is e.g. "filename\0\0\0\0\0\0[...]"

With Qt < 5.6 this would lead to name being equal to "filename".

With Qt 5.6 from git, it leads to name being equal to "filename\0\0\0\0\0etc.".

It appears that QUtfCodec doesn't stop at the first null byte anymore.

This appears to fix it:
-        name = QFile::decodeName(QByteArray(buffer, 100));
+        name = QFile::decodeName(QByteArray(buffer, qstrnlen(buffer, 100)));

but I have to find the other places in there, some more unittests still fail.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5



More information about the Kde-frameworks-devel mailing list