Skip to content

Commit 517e507

Browse files
committed
Fix crash in QVector::reserve when reserving smaller size on a shared vector
This backport part of the commit 480b395 Task-number: QTBUG-6416
1 parent ce4522c commit 517e507

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/corelib/tools/qvector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void QVector<T>::detach_helper()
315315
{ realloc(d->size, d->alloc); }
316316
template <typename T>
317317
void QVector<T>::reserve(int asize)
318-
{ if (asize > d->alloc || d->ref != 1) realloc(d->size, asize); d->capacity = 1; }
318+
{ if (asize > d->alloc) realloc(d->size, asize); if (d->ref == 1) d->capacity = 1; }
319319
template <typename T>
320320
void QVector<T>::resize(int asize)
321321
{ realloc(asize, (asize > d->alloc || (!d->capacity && asize < d->size && asize < (d->alloc >> 1))) ?

0 commit comments

Comments
 (0)