forked from qt-creator/qt-creator
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:
@@ -666,7 +666,9 @@ QString decodeData(const QString &ba, const QString &encoding)
|
|||||||
qDebug("not implemented"); // Only used in Arrays, see watchdata.cpp
|
qDebug("not implemented"); // Only used in Arrays, see watchdata.cpp
|
||||||
return QString();
|
return QString();
|
||||||
case DebuggerEncoding::HexEncodedFloat: {
|
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) {
|
if (enc.size == 4) {
|
||||||
union { char c[4]; float f; } u = {{s[3], s[2], s[1], s[0]}};
|
union { char c[4]; float f; } u = {{s[3], s[2], s[1], s[0]}};
|
||||||
return QString::number(u.f);
|
return QString::number(u.f);
|
||||||
|
Reference in New Issue
Block a user