Page 1 of 1

Qt4 GUI: segfault if initSimulation fails fixed

Posted: 28.09.2011, 10:20
by refsteff
Hello,

If CelestiaCore->initSimulation fails (configfile errors, spice initialization fails, reading of star catalogs etc.), you got an error message and
celestia crashes immediately with an segmentation fault if it call functions that depends on correct initialization.
The reason is that the return value of m_appCore->initSimulation in qtappwin.cpp is not checked.

This patch fixes it:

Code: Select all

diff -urN celestia.org/src/celestia/qt/qtappwin.cpp celestia/src/celestia/qt/qtappwin.cpp
--- celestia.org/src/celestia/qt/qtappwin.cpp   2011-08-19 16:04:59.000000000 +0200
+++ celestia/src/celestia/qt/qtappwin.cpp   2011-09-28 11:39:50.512427214 +0200
@@ -225,9 +225,14 @@
 
    setWindowIcon(QIcon(":/icons/celestia.png"));
 
-    m_appCore->initSimulation(&configFileName,
+    if(!m_appCore->initSimulation(&configFileName,
                             &extrasDirectories,
-                            progress);
+                            progress))
+    {
+        delete progress
+        exit(1);
+    }
+
     delete progress;
 
    // Enable antialiasing if requested in the config file.

I adapted this patch from the kde code.

See you

refsteff