diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-07-28 16:30:45 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-08-01 14:06:18 +0200 |
| commit | 9df4293adf7d019b4d3ccaaa2f5d87ddfe0b041b (patch) | |
| tree | 00a4263f24751568e62c816e8f1be75ce44621af /src/qml/compiler/qv4codegen.cpp | |
| parent | 115916f217b0dc299b8df298f5c9c30369f561f8 (diff) | |
UndefinedBehavior: fix some things found with -sanitize undefined
Here are the sorts of things that were found:
- Uninitialized variables containing garbage.
- Calling member function through nullptr (where this is not actually
used inside the function because that would trigger a segfault).
- static_cast'ing double to int where the double is either +/-infinity
or is outside the range of min and max values for int.
Additionally, the uses of QJSNumberCoercion::isInteger() in the code
generator have been replaced by QJSNumberCoercion::isArrayIndex() and
the former was deprecated as it is no longer being used.
Pick-to: 6.5 6.6
Change-Id: I9318671ccbda37e5519f4fcb84a1537585c2103f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
| -rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index f9c4398490..c43bdd8387 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -4625,7 +4625,7 @@ QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty str StaticValue p = StaticValue::fromReturnedValue(constant); if (p.isNumber()) { double d = p.asDouble(); - int i = static_cast<int>(d); + int i = QJSNumberCoercion::toInteger(d); if (d == i && (d != 0 || !std::signbit(d))) { if (!i) { Instruction::LoadZero load; |
