[Kstars-devel] KDE/kdeedu/kstars/kstars

Alexey Khudyakov alexey.skladnoy at gmail.com
Sun Aug 23 13:06:41 CEST 2009


SVN commit 1014575 by khudyakov:

Zero out pinstance after deletion to prevent possibility of dangling
pointer.

State where does pinstance is set in comment.

CCMAIL: kstars-devel at kde.org

 M  +6 -3      kstars.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/kstars.cpp #1014574:1014575
@@ -125,10 +125,13 @@
 }
 
 KStars *KStars::createInstance( bool doSplash, bool clockrun, const QString &startdate ) {
-    if( pinstance )
+    if( pinstance ) {
         delete pinstance;
-    pinstance = new KStars( doSplash, clockrun, startdate );
-    Q_ASSERT( pinstance );
+        pinstance = 0;
+    }
+    // pinstance is set directly in constructor.
+    new KStars( doSplash, clockrun, startdate );
+    Q_ASSERT( pinstance && "pinstance must be non NULL");
     return pinstance;
 }
 


More information about the Kstars-devel mailing list