diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-28 13:49:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-28 13:20:24 +0000 |
commit | 854c15cdb64f9693fc8d90f73464d499ebdca4fd (patch) | |
tree | bf96694a0289d2b58df4af6e4c937c7dddc83d86 /src | |
parent | 56a2b70247270c780247a1d2dcc670c3f0f5ab80 (diff) |
Fix a crash in the modulus operation
INT_MIN % -1 crashes in C++ with an arithmetic exception, so
avoid passing negative numbers into the integer operation, use
fmod() instead.
Task-number: QTBUG-68513
Change-Id: Ib5a37b55a0f9d41a84c7e6c00ea3f87622155de5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 0211ad1011..9729228511 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1408,7 +1408,7 @@ ReturnedValue Runtime::method_mod(const Value &left, const Value &right) { TRACE2(left, right); - if (Value::integerCompatible(left, right) && right.integerValue() != 0) { + if (Value::integerCompatible(left, right) && left.integerValue() > 0 && right.integerValue() > 0) { int intRes = left.integerValue() % right.integerValue(); if (intRes != 0 || left.integerValue() >= 0) return Encode(intRes); |