aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stringobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4stringobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 5f3d833f33..40d176723b 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -1012,6 +1012,11 @@ ReturnedValue StringPrototype::method_startsWith(const FunctionObject *b, const
if (argc > 1)
pos = argv[1].toInteger();
+ pos = std::clamp(
+ pos,
+ 0.0,
+ double(value.size()));
+
if (pos == 0)
return Encode(value.startsWith(searchString));