diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-11-26 12:22:36 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-27 12:22:27 +0100 |
commit | 3c9c35b648e32082b30786fe71d4db33ffe2b5a6 (patch) | |
tree | 9973e83ec78dd6a366ab3cdb72e804c7561cf755 /src/qml/jsruntime | |
parent | 900e3d4ad5f2bc4994ddf164c15c641f85630b81 (diff) |
Prospective fix for crashes when sorting JS arrays on Windows
std::sort doesn't seem to like sorting empty arrays, so check the
size before sorting.
Task-number: QTBUG-33658
Change-Id: I841259939ea3bf850d23c129744c322ed46a95fe
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index e4df95716d..743d35fa69 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -1262,13 +1262,9 @@ void Object::arraySort(ExecutionContext *context, ObjectRef thisObject, const Va ArrayElementLessThan lessThan(context, thisObject, comparefn); + if (!len) + return; Property *begin = arrayData; - // We deliberately choose qSort over std::sort here, because with - // MSVC in debug builds, std::sort has an ASSERT() that verifies - // that the return values of lessThan are perfectly consistent - // and aborts otherwise. We do not want JavaScript to easily crash - // the entire application and therefore choose qSort, which doesn't - // have this property. std::sort(begin, begin + len, lessThan); } |