aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine/tst_qjsengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qjsengine/tst_qjsengine.cpp')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 87549d2019..741fa9f04d 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -127,6 +127,7 @@ private slots:
void reentrancy_objectCreation();
void jsIncDecNonObjectProperty();
void JSONparse();
+ void arraySort();
void qRegExpInport_data();
void qRegExpInport();
@@ -2742,6 +2743,24 @@ void tst_QJSEngine::JSONparse()
QVERIFY(ret.isObject());
}
+void tst_QJSEngine::arraySort()
+{
+ // tests that calling Array.sort with a bad sort function doesn't cause issues
+ // Using std::sort is e.g. not safe when used with a bad sort function and causes
+ // crashes
+ QJSEngine eng;
+ eng.evaluate("function crashMe() {"
+ " var data = [];"
+ " for (var i = 0; i < 50; i++) {"
+ " data[i] = 'whatever';"
+ " }"
+ " data.sort(function(a, b) {"
+ " return -1;"
+ " });"
+ "}"
+ "crashMe();");
+}
+
static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; }
void tst_QJSEngine::qRegExpInport_data()