From f87a7bebe9e67b48a3be4a7447bfb87e419c68f6 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 23 Sep 2020 17:24:46 +0200 Subject: [PATCH] Debugger: Make decoding hex-encoded floats more robust Apparently, the values are sometimes transmitted without leading zeroes, so insert them if they are missing. This fixes a crash in the QV4 dumper test. Change-Id: I7434c9c090524eecbf5c50e69ad49f5a6ca81e1a Reviewed-by: hjk --- src/plugins/debugger/debuggerprotocol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 71f9f4233d0..ccd834636c6 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -666,7 +666,9 @@ QString decodeData(const QString &ba, const QString &encoding) qDebug("not implemented"); // Only used in Arrays, see watchdata.cpp return QString(); case DebuggerEncoding::HexEncodedFloat: { - const QByteArray s = QByteArray::fromHex(ba.toUtf8()); + QByteArray s = QByteArray::fromHex(ba.toUtf8()); + if (s.size() < enc.size) + s.prepend(QByteArray(enc.size - s.size(), '\0')); if (enc.size == 4) { union { char c[4]; float f; } u = {{s[3], s[2], s[1], s[0]}}; return QString::number(u.f);