From 854c15cdb64f9693fc8d90f73464d499ebdca4fd Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 May 2018 13:49:40 +0200 Subject: 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 --- src/qml/jsruntime/qv4runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/jsruntime/qv4runtime.cpp') 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); -- cgit v1.2.3