aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-04-08 14:45:23 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-04-08 13:48:24 +0000
commit78787011651692b64bef19f6bec03d0dbf390e18 (patch)
tree21e1b71bb53b2e6a0a1cee65c1ecfa35c5d0087b /src/qml/jsruntime
parent651177db69a61278da5bc1b2434b8e7f291d5636 (diff)
Avoid INT_MIN % -1 and INT_MIN / -1
Those throw arithmetic exceptions as the result doesn't fit into an integer. Fixes: QTBUG-75030 Change-Id: Ibd978848f42cf1c9da1e4af2dc9d7da123ef8f5a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 85d06bcabe..6a242ba5f6 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1942,6 +1942,7 @@ ReturnedValue Runtime::method_div(const Value &left, const Value &right)
int lval = left.integerValue();
int rval = right.integerValue();
if (rval != 0 // division by zero should result in a NaN
+ && !(lval == std::numeric_limits<int>::min() && rval == -1) // doesn't fit in int
&& (lval % rval == 0) // fractions can't be stored in an int
&& !(lval == 0 && rval < 0)) // 0 / -something results in -0.0
return Encode(int(lval / rval));