Fix access to uninitialized pointer
authorTobias Hunger <tobias.hunger@nokia.com>
Sat, 16 Jun 2012 20:52:03 +0000 (22:52 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 20 Jun 2012 01:18:07 +0000 (03:18 +0200)
The C++ standard says in 9.4..2 that the object expression is evaluated,
so any compliant compiler may access d. So this syntax is a bug in this
place.

Change-Id: I37d2c4ea54febd40410ca473c906bcb1c66c4974
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
src/corelib/tools/qsharedpointer_impl.h

index 4a1a499..46cd1cc 100644 (file)
@@ -512,7 +512,7 @@ public:
     // special constructor that is enabled only if X derives from QObject
 #if QT_DEPRECATED_SINCE(5, 0)
     template <class X>
-    QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr)
+    QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : 0), value(ptr)
     { }
 #endif
 #endif