Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH] phonesim: Free some resources after client disconnects.
@ 2010-04-20  4:44 Andrzej Zaborowski
  2010-04-20 20:42 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Andrzej Zaborowski @ 2010-04-20  4:44 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-20 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-20  4:44 [PATCH] phonesim: Free some resources after client disconnects Andrzej Zaborowski
2010-04-20 20:42 ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox