diff options
| author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-08-01 15:20:58 +0200 |
|---|---|---|
| committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-08-02 13:59:11 +0000 |
| commit | 3a36c19befa0d30d41ee19de33c95e8f7af20557 (patch) | |
| tree | 4dffe59cd440d803d040431b8f3cae2f9a49d88d /src | |
| parent | 1c3f91e5e4350a944b9dad3fe5d1c3cae56989b4 (diff) | |
Fix unary minus: -UINT_MIN is not an integer
Change-Id: I460273c19784aeb36e2e17e1bfb3c0b3e4f7f09b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 3 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index d474f45237..b9ea73f6a8 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1496,7 +1496,8 @@ ReturnedValue Runtime::method_uMinus(const Value &value) TRACE1(value); // +0 != -0, so we need to convert to double when negating 0 - if (value.isInteger() && value.integerValue()) + if (value.isInteger() && value.integerValue() && + value.integerValue() != std::numeric_limits<int>::min()) return Encode(-value.integerValue()); else { double n = RuntimeHelpers::toNumber(value); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index df7ba789e1..ca2d611035 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -825,7 +825,8 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code) MOTH_END_INSTR(UPlus) MOTH_BEGIN_INSTR(UMinus) - if (Q_LIKELY(accumulator.isInteger() && accumulator.int_32() != 0)) { + if (Q_LIKELY(accumulator.isInteger() && accumulator.int_32() != 0 && + accumulator.int_32() != std::numeric_limits<int>::min())) { accumulator = sub_int32(0, accumulator.int_32()); } else { STORE_ACCUMULATOR(Runtime::method_uMinus(accumulator)); |
