diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-10-22 13:27:11 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-10-22 16:20:01 (GMT) |
commit | 3bb0cf4ad7166860fb7b81b1bbe1d84d86d4203c (patch) | |
tree | 1decd3ba5eac7b7f03706e7750e8cce3cd230f85 /src/corelib/tools | |
parent | a3c2f84f1a33610b86a600c68653b96de1d2b9f5 (diff) | |
download | Qt-3bb0cf4ad7166860fb7b81b1bbe1d84d86d4203c.zip Qt-3bb0cf4ad7166860fb7b81b1bbe1d84d86d4203c.tar.gz Qt-3bb0cf4ad7166860fb7b81b1bbe1d84d86d4203c.tar.bz2 |
Fix access to uninitialised memory in case of new throwing
Testing will come later with a full test for exception issues
Task-number: QTBUG-14637
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 4cce339..2519a22 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -378,6 +378,13 @@ namespace QtSharedPointer { inline ExternalRefCount() : d(0) { } inline ExternalRefCount(Qt::Initialization i) : Basic<T>(i) { } + + inline ExternalRefCount(T *ptr) : Basic<T>(Qt::Uninitialized) // throws + { internalConstruct(ptr); } + template <typename Deleter> + inline ExternalRefCount(T *ptr, Deleter d) : Basic<T>(Qt::Uninitialized) // throws + { internalConstruct(ptr, d); } + inline ExternalRefCount(const ExternalRefCount<T> &other) : Basic<T>(other), d(other.d) { if (d) ref(); } template <class X> @@ -448,11 +455,12 @@ public: inline QSharedPointer() { } // inline ~QSharedPointer() { } - inline explicit QSharedPointer(T *ptr) : BaseClass(Qt::Uninitialized) - { BaseClass::internalConstruct(ptr); } + inline explicit QSharedPointer(T *ptr) : BaseClass(ptr) // throws + { } template <typename Deleter> - inline QSharedPointer(T *ptr, Deleter d) { BaseClass::internalConstruct(ptr, d); } + inline QSharedPointer(T *ptr, Deleter d) : BaseClass(ptr, d) // throws + { } inline QSharedPointer(const QSharedPointer<T> &other) : BaseClass(other) { } inline QSharedPointer<T> &operator=(const QSharedPointer<T> &other) |