From c9f7531f177b051720e2f480bcb3a941fbd7510a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 13 Feb 2025 23:34:36 +0100 Subject: [PATCH] Fixed broken strings handling under Qt5 --- src/data.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/data.cpp b/src/data.cpp index 8dcf9c2..9a85d2f 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -60,7 +60,14 @@ static bool str(CTX &ctx, QByteArray &val) if (ctx.bp + len > ctx.be) return false; +/* In Qt5 the (later) conversion to QString is broken when the QByteArray is + not nul terminated so we have to use the "deep copy" constructor that + nul-terminates the byte array when it is created. */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + val = QByteArray(ctx.bp, len); +#else val = QByteArray::fromRawData(ctx.bp, len); +#endif ctx.bp += len; return true;