Also zero SimRules::toolkitApp to avoid segfaults before the field
is initialised.

Note there may be more places leaking resources.
---
 src/phonesim.cpp |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/phonesim.cpp b/src/phonesim.cpp
index d363c29..d5d7d87 100644
--- a/src/phonesim.cpp
+++ b/src/phonesim.cpp
@@ -501,6 +501,7 @@ SimRules::SimRules( int fd, QObject *p,  const QString& 
filename, HardwareManipu
 {
     setSocketDescriptor(fd);
     machine = 0;
+    toolkitApp = 0;
 
     if (hmf)
         machine = hmf->create(this, 0);
@@ -554,6 +555,7 @@ SimRules::SimRules( int fd, QObject *p,  const QString& 
filename, HardwareManipu
     SimXmlHandler *handler = new SimXmlHandler();
     if ( !readXmlFile( handler, filename ) ) {
         qWarning() << filename << ": could not parse simulator rule file";
+        delete handler;
         return;
     }
 
@@ -837,6 +839,26 @@ void SimRules::tryReadCommand()
 
 void SimRules::destruct()
 {
+    if ( toolkitApp != defaultToolkitApp )
+        delete toolkitApp;
+    delete defaultToolkitApp;
+    toolkitApp = NULL;
+
+    if ( getMachine() )
+        getMachine()->handleNewApp();
+
+    if ( defState )
+        delete defState;
+    defState = NULL;
+
+    if ( _callManager )
+        delete _callManager;
+    _callManager = NULL;
+
+    if ( fileSystem )
+        delete fileSystem;
+    fileSystem = NULL;
+
     if (machine) machine->deleteLater();
     deleteLater();
 }
-- 
1.6.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to