diff --git a/src/libs/qmldebug/qpacketprotocol.cpp b/src/libs/qmldebug/qpacketprotocol.cpp index 9364ffbbbff..76b641a6a5b 100644 --- a/src/libs/qmldebug/qpacketprotocol.cpp +++ b/src/libs/qmldebug/qpacketprotocol.cpp @@ -29,8 +29,6 @@ namespace QmlDebug { -static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF; - /*! \class QPacketProtocol \internal @@ -98,8 +96,7 @@ class QPacketProtocolPrivate : public QObject public: QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev) - : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE), - waitingForPacket(false), dev(_dev) + : QObject(parent), inProgressSize(-1), waitingForPacket(false), dev(_dev) { Q_ASSERT(4 == sizeof(qint32)); @@ -152,12 +149,12 @@ public: return; // Read size header - int read = dev->read((char *)&inProgressSize, sizeof(qint32)); + const qint64 read = dev->read((char *)&inProgressSize, sizeof(qint32)); Q_ASSERT(read == sizeof(qint32)); Q_UNUSED(read); // Check sizing constraints - if (inProgressSize > maxPacketSize) { + if (inProgressSize < qint32(sizeof(qint32))) { QObject::disconnect(dev, &QIODevice::readyRead, this, &QPacketProtocolPrivate::readyToRead); QObject::disconnect(dev, &QIODevice::aboutToClose, @@ -191,7 +188,6 @@ public: QList packets; QByteArray inProgress; qint32 inProgressSize; - qint32 maxPacketSize; bool waitingForPacket; QIODevice *dev; }; diff --git a/src/plugins/qmlprofiler/qmltypedevent.cpp b/src/plugins/qmlprofiler/qmltypedevent.cpp index 30bfeb9b705..5eec5d082b6 100644 --- a/src/plugins/qmlprofiler/qmltypedevent.cpp +++ b/src/plugins/qmlprofiler/qmltypedevent.cpp @@ -42,9 +42,8 @@ QDataStream &operator>>(QDataStream &stream, QmlTypedEvent &event) RangeType rangeType = MaximumRangeType; if (!stream.atEnd()) { stream >> subtype; - rangeType = static_cast(subtype); - if (rangeType < 0 || rangeType > MaximumRangeType) - rangeType = MaximumRangeType; + if (subtype >= 0 && subtype < MaximumRangeType) + rangeType = static_cast(subtype); } else { subtype = -1; }