Module: sems
Branch: master
Commit: 6b7ebda3c94949a1861d993972c2a422ef1ab031
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=6b7ebda3c94949a1861d993972c2a422ef1ab031

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Thu Feb 24 00:27:27 2011 +0100

b/f: small mem leak (AmSdp telev pl)

...which keeps popping up all the time again...

---

 core/AmSdp.cpp |   12 +++++++++---
 core/AmSdp.h   |    9 +++++----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/AmSdp.cpp b/core/AmSdp.cpp
index 6ff9bcc..6bd6e1e 100644
--- a/core/AmSdp.cpp
+++ b/core/AmSdp.cpp
@@ -162,11 +162,17 @@ int AmSdp::parse()
     }
   }
   
-  telephone_event_pt = findPayload("telephone-event");
+  telephone_event_pt.reset(findPayload("telephone-event"));
     
   return ret;
 }
 
+SdpPayload* AmSdp::telephoneEventPayload() const {
+  if (telephone_event_pt.get() == NULL)
+    return NULL;
+  return new SdpPayload(*telephone_event_pt.get());
+}
+
 void AmSdp::print(string& body) const
 {
   string out_buf =
@@ -444,10 +450,10 @@ const vector<SdpPayload*>& 
AmSdp::getCompatiblePayloads(AmPayloadProviderInterfa
        
 bool AmSdp::hasTelephoneEvent()
 {
-  return telephone_event_pt != NULL;
+  return telephone_event_pt.get() != NULL;
 }
 
-const SdpPayload *AmSdp::findPayload(const string& name)
+SdpPayload *AmSdp::findPayload(const string& name)
 {
   vector<SdpMedia>::iterator m_it;
 
diff --git a/core/AmSdp.h b/core/AmSdp.h
index 7769a9f..9120539 100644
--- a/core/AmSdp.h
+++ b/core/AmSdp.h
@@ -33,6 +33,7 @@
 #include <vector>
 #include <netinet/in.h>
 #include "AmPlugIn.h"
+#include <memory>
 using std::string;
 
 
@@ -157,12 +158,12 @@ class AmSdp
 
   // Remote payload type for 
   // 'telephone-event'
-  const SdpPayload *telephone_event_pt;
+  std::auto_ptr<SdpPayload> telephone_event_pt;
 
   /**
-   * Find payload by name
+   * Find payload by name, return cloned object
    */
-  const SdpPayload *findPayload(const string& name);
+  SdpPayload *findPayload(const string& name);
 
 public:
   // parsed SDP definition
@@ -226,7 +227,7 @@ public:
    */
   bool hasTelephoneEvent();
 
-  const SdpPayload *telephoneEventPayload() const { return telephone_event_pt; 
}
+  SdpPayload *telephoneEventPayload() const;
 };
 
 #endif

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to