From 78787011651692b64bef19f6bec03d0dbf390e18 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 8 Apr 2019 14:45:23 +0200 Subject: 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 --- src/qml/jsruntime/qv4runtime.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qml/jsruntime') 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::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)); -- cgit v1.2.3