From 96836e849f958a3b4417454874d434ae6a26b3fb Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sat, 22 Jan 2022 19:14:52 +0100 Subject: [PATCH] Fix handling of null terminated ANI metadata with Qt6 In Qt5 converting a QByteArray to a QString stops at the first null byte, in Qt6 the QByteArray size is respected, and trailing null bytes are therefore included in the final QString. Explicitly determine the length of the string data to deal with that. --- src/imageformats/ani.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/imageformats/ani.cpp b/src/imageformats/ani.cpp index 9bf3470..3fa7c83 100644 --- a/src/imageformats/ani.cpp +++ b/src/imageformats/ani.cpp @@ -12,6 +12,8 @@ #include #include +#include + namespace { struct ChunkHeader { @@ -419,7 +421,7 @@ bool ANIHandler::ensureScanned() const } // FIXME encoding - const QString stringValue = QString::fromLocal8Bit(value); + const QString stringValue = QString::fromLocal8Bit(value.constData(), std::strlen(value.constData())); if (chunkId == "INAM") { mutableThis->m_name = stringValue; } else if (chunkId == "IART") {