diff options
-rw-r--r-- | src/corelib/tools/qlist.h | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c6dd106..dc8c849 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -636,12 +636,10 @@ inline void QList<T>::move(int from, int to) template<typename T> Q_OUTOFLINE_TEMPLATE QList<T> QList<T>::mid(int pos, int alength) const { - if (alength < 0) + if (alength < 0 || pos + alength > size()) alength = size() - pos; if (pos == 0 && alength == size()) return *this; - if (pos + alength > size()) - alength = size() - pos; QList<T> cpy; cpy.reserve(alength); cpy.d->end = alength; |