Fix crashes when calling Array.sort with imperfect sort functions
authorLars Knoll <lars.knoll@digia.com>
Thu, 12 Jun 2014 12:35:53 +0000 (14:35 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 1 Sep 2014 10:23:46 +0000 (12:23 +0200)
commit210475565969ca5381174016b47cd32ddc96eaed
tree59d76471cc7d602c3a8bf3893fa87adfd3383097
parentcf44ee7761f2e4175f9193b42ee7296a2f3b694a
Fix crashes when calling Array.sort with imperfect sort functions

We can't use std::sort to implement Array.sort. The reason is that
std::sort expects a conformant compare function, and can do weird
things (esp. crash) when the sort function isn't conformant.

Falling back to qSort is not possible, as the method has been
deprecated. So add a copy of the qSort implementation here, and
use that one instead.

Fix the sortint test in tst_qqmlecmascript to have a consistent
sort function for strings, as the result of calling sort is
otherwise undefined according to the ecma standard.

Task-number: QTBUG-39072
Change-Id: I0602b3aa1ffa4de5006da58396f166805cf4a5e2
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4arraydata.cpp
tests/auto/qml/qjsengine/tst_qjsengine.cpp
tests/auto/qml/qqmlecmascript/data/sequenceSort.qml