forked from qt-creator/qt-creator
QmlDebug/QmlProfiler: Fix integer range checks
The packet protocol should check if the number of bytes to be read is positive. The check in QmlTypedEvent is supposed to happen before we cast the number to the more restrictive type. Furthermore, if subtype doesn't fit the range constraint, we don't have to do anything at all as the default rangeType is already set before. Change-Id: I45006f8dd752787d59960948b222148d78509aba Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -42,9 +42,8 @@ QDataStream &operator>>(QDataStream &stream, QmlTypedEvent &event)
|
||||
RangeType rangeType = MaximumRangeType;
|
||||
if (!stream.atEnd()) {
|
||||
stream >> subtype;
|
||||
rangeType = static_cast<RangeType>(subtype);
|
||||
if (rangeType < 0 || rangeType > MaximumRangeType)
|
||||
rangeType = MaximumRangeType;
|
||||
if (subtype >= 0 && subtype < MaximumRangeType)
|
||||
rangeType = static_cast<RangeType>(subtype);
|
||||
} else {
|
||||
subtype = -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user