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 <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2020-09-23 17:24:46 +02:00
parent 822aa7b242
commit f87a7bebe9

View File

@@ -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);