From 40425ea53e2fafcfc3fe8357459da1a083660657 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 16 May 2011 10:48:05 +0200 Subject: Fix a regression in QList::mid() It doesn't need to copy anything when pos is after size(). Task-number: QTBUG-19164 Reviewed-by: Oswald Buddenhagen (cherry picked from commit 8befc4982a32752e48c82cacbed045e7336a3569) Change-Id: Iccac75842616f0d41e457e844a15d1a3ccfeb642 Reviewed-on: http://codereview.qt.nokia.com/164 Reviewed-by: Liang Qi --- src/corelib/tools/qlist.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index e6f041fe3c..4eb05d63b6 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -641,6 +641,8 @@ Q_OUTOFLINE_TEMPLATE QList QList::mid(int pos, int alength) const if (pos == 0 && alength == size()) return *this; QList cpy; + if (alength <= 0) + return cpy; cpy.reserve(alength); cpy.d->end = alength; QT_TRY { -- cgit v1.2.3