diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-16 13:35:13 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:19:41 +0000 |
commit | 613dede03b1fa742027072c5656ef6ccefc651ad (patch) | |
tree | b9781c912b3a89ff39ad9a533513706002939a42 /src/qml/jsruntime/qv4arrayobject.cpp | |
parent | f1162921dfba638585f2c10760443df003ae7e4c (diff) |
Fixes when using getLength()
Do some more bounds checking to avoid crashes.
Change-Id: I44e838c3577a9176628aa5e382d712eac9800203
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4arrayobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 9b9a2f1052..2bc5ec1de1 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -352,7 +352,7 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value * instance->arrayCreate(); Q_ASSERT(instance->arrayData()); - quint64 len = instance->getLength(); + qint64 len = instance->getLength(); if (len + quint64(argc) >= UINT_MAX) { // ughh... this goes beyond UINT_MAX @@ -393,7 +393,7 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value * return scope.engine->throwTypeError(); } - return Encode(len); + return Encode(uint(len)); } ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Value *thisObject, const Value *, int) @@ -403,7 +403,10 @@ ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Valu if (!instance) RETURN_UNDEFINED(); - uint length = instance->getLength(); + qint64 length = instance->getLength(); + // ### FIXME + if (length >= UINT_MAX) + return scope.engine->throwRangeError(QLatin1String("Array.prototype.reverse: Length out of range.")); int lo = 0, hi = length - 1; |