diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-02 13:35:09 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-02 13:36:32 (GMT) |
commit | 517e50706b154254bb2b51f19b8678c6a8df2590 (patch) | |
tree | 7a1a9e6059eaa1acce03809c555f2753020712ac | |
parent | ce4522cb341340e98427d678664ea84761e3ca07 (diff) | |
download | Qt-517e50706b154254bb2b51f19b8678c6a8df2590.zip Qt-517e50706b154254bb2b51f19b8678c6a8df2590.tar.gz Qt-517e50706b154254bb2b51f19b8678c6a8df2590.tar.bz2 |
Fix crash in QVector::reserve when reserving smaller size on a shared vector
This backport part of the commit 480b395bd652a4ac6e3f2
Task-number: QTBUG-6416
-rw-r--r-- | src/corelib/tools/qvector.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 6c78abb..2e88d6b 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -315,7 +315,7 @@ void QVector<T>::detach_helper() { realloc(d->size, d->alloc); } template <typename T> void QVector<T>::reserve(int asize) -{ if (asize > d->alloc || d->ref != 1) realloc(d->size, asize); d->capacity = 1; } +{ if (asize > d->alloc) realloc(d->size, asize); if (d->ref == 1) d->capacity = 1; } template <typename T> void QVector<T>::resize(int asize) { realloc(asize, (asize > d->alloc || (!d->capacity && asize < d->size && asize < (d->alloc >> 1))) ? |