diff options
author | Fabian Bumberger <fbumberger@rim.com> | 2012-08-24 18:36:16 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-30 18:44:13 (GMT) |
commit | 24d4234f6b86095d5ab84fa2071d0890be2154d5 (patch) | |
tree | ca92dfe1d008250a40205a54c8c0d68d5b6f5776 /src/corelib | |
parent | aa21fcac3672cc6f0dca064b34bbe02ca4f4def7 (diff) | |
download | Qt-24d4234f6b86095d5ab84fa2071d0890be2154d5.zip Qt-24d4234f6b86095d5ab84fa2071d0890be2154d5.tar.gz Qt-24d4234f6b86095d5ab84fa2071d0890be2154d5.tar.bz2 |
Fixes possible memory leak in QContiguousCache
When inserting an item on a position that is already occupied, the destructor of the old item was never invoked.
Qt5 SHA1: b4075c8ea31b235cdbb61fcd6290105b9914d627
Change-Id: I842fd81f284d9ca58760bce7e1adfea84da0a788
Reviewed-by: Peter Hartmann <phartmann@rim.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index b360850..9a6b9e3 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -392,10 +392,12 @@ void QContiguousCache<T>::insert(int pos, const T &value) Q_ASSERT_X(pos >= 0 && pos < INT_MAX, "QContiguousCache<T>::insert", "index out of range"); detach(); if (containsIndex(pos)) { - if(QTypeInfo<T>::isComplex) + if (QTypeInfo<T>::isComplex) { + (p->array + pos % d->alloc)->~T(); new (p->array + pos % d->alloc) T(value); - else + } else { p->array[pos % d->alloc] = value; + } } else if (pos == d->offset-1) prepend(value); else if (pos == d->offset+d->count) |