first attempt to properly copy and then free call detail strings.
authorJeremy McNamara <jj@nufone.net>
Tue, 20 Jul 2004 21:04:16 +0000 (21:04 +0000)
committerJeremy McNamara <jj@nufone.net>
Tue, 20 Jul 2004 21:04:16 +0000 (21:04 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3485 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_h323.c
channels/h323/ast_h323.cpp

index db2ec98..9c5724e 100755 (executable)
@@ -1054,12 +1054,12 @@ int setup_incoming_call(call_details_t cd)
        }
 
        /* Populate the call details in the private structure */
        }
 
        /* Populate the call details in the private structure */
-       p->cd.call_token = cd.call_token;
-       p->cd.call_source_aliases = cd.call_source_aliases;
-       p->cd.call_dest_alias = cd.call_dest_alias;
-       p->cd.call_source_name = cd.call_source_name;
-       p->cd.call_source_e164 = cd.call_source_e164;
-       p->cd.call_dest_e164 = cd.call_dest_e164;
+       p->cd.call_token = strdup(cd.call_token);
+       p->cd.call_source_aliases = strdup(cd.call_source_aliases);
+       p->cd.call_dest_alias = strdup(cd.call_dest_alias);
+       p->cd.call_source_name = strdup(cd.call_source_name);
+       p->cd.call_source_e164 = strdup(cd.call_source_e164);
+       p->cd.call_dest_e164 = strdup(cd.call_dest_e164);
 
        if (h323debug) {
                ast_verbose(VERBOSE_PREFIX_3 "Setting up Call\n");
 
        if (h323debug) {
                ast_verbose(VERBOSE_PREFIX_3 "Setting up Call\n");
@@ -1291,6 +1291,32 @@ void chan_ringing(unsigned call_reference)
         return;
 }
 
         return;
 }
 
+
+void cleanup_call_details(call_details_t cd) 
+{
+        if (cd.call_token) {
+                free((const char*)cd.call_token);
+        }
+        if (cd.call_source_aliases) {
+                free((const char*)cd.call_source_aliases);
+        }
+        if (cd.call_dest_alias) {
+                free((const char*)cd.call_dest_alias);
+       }
+        if (cd.call_source_name) { 
+                free((const char*)cd.call_source_name);
+        }
+        if (cd.call_source_e164) {
+                free((const char*)cd.call_source_e164);
+        }
+        if (cd.call_dest_e164) {
+                free((const char*)cd.call_dest_e164);
+        }
+        if (cd.sourceIp) {
+                free((const char*)cd.sourceIp);
+        }
+}
+
 /**
   * Call-back function to cleanup communication
   * Returns nothing,
 /**
   * Call-back function to cleanup communication
   * Returns nothing,
@@ -1335,6 +1361,8 @@ void cleanup_connection(call_details_t cd)
                ast_rtp_destroy(rtp);
        }
 
                ast_rtp_destroy(rtp);
        }
 
+       cleanup_call_details(p->cd);
+       
        p->alreadygone = 1;
        
        /* Send hangup */       
        p->alreadygone = 1;
        
        /* Send hangup */       
index d67e95f..0e52068 100755 (executable)
@@ -375,11 +375,11 @@ void MyH323EndPoint::OnConnectionCleared(H323Connection & connection, const PStr
        remoteName = connection.GetRemotePartyName();
 
        cd.call_reference = connection.GetCallReference();
        remoteName = connection.GetRemotePartyName();
 
        cd.call_reference = connection.GetCallReference();
-       cd.call_token = (const char *)clearedCallToken;
-       cd.call_source_aliases = (const char *)connection.GetRemotePartyName();
+       cd.call_token = strdup((const char *)clearedCallToken);
+       cd.call_source_aliases = strdup((const char *)connection.GetRemotePartyName());
        
        connection.GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
        
        connection.GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
-       cd.sourceIp = (const char *)Ip.AsString();
+       cd.sourceIp = strdup((const char *)Ip.AsString());
        
        /* Convert complex strings */
        char *s;
        
        /* Convert complex strings */
        char *s;
@@ -539,7 +539,6 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
        PString sourceName;
        PString sourceAliases;  
        PString destAliases;
        PString sourceName;
        PString sourceAliases;  
        PString destAliases;
-       PString sourceIp;
        PIPSocket::Address Ip;
        WORD sourcePort;
        char *s, *s1; 
        PIPSocket::Address Ip;
        WORD sourcePort;
        char *s, *s1; 
@@ -567,18 +566,15 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
 
 
        cd.call_reference = GetCallReference();
 
 
        cd.call_reference = GetCallReference();
-       cd.call_token = (const char *)GetCallToken();
-       cd.call_source_aliases  = (const char *)sourceAliases;
-       cd.call_dest_alias = (const char *)destAliases;
-       cd.call_source_e164 = (const char *)sourceE164;
-       cd.call_dest_e164 = (const char *)destE164;
-       cd.call_source_name = (const char *)sourceName;
+       cd.call_token = strdup((const char *)GetCallToken());
+       cd.call_source_aliases  =  strdup((const char *)sourceAliases);
+       cd.call_dest_alias = strdup((const char *)destAliases);
+       cd.call_source_e164 = strdup((const char *)sourceE164);
+       cd.call_dest_e164 = strdup((const char *)destE164);
+       cd.call_source_name = strdup((const char *)sourceName);
 
        GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
 
        GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
-       sourceIp = Ip.AsString();
-       cd.sourceIp = (const char *)sourceIp;
-       
-
+       cd.sourceIp = strdup((const char *)Ip.AsString());
 
        /* Notify Asterisk of the request */
        int res = on_incoming_call(cd); 
 
        /* Notify Asterisk of the request */
        int res = on_incoming_call(cd); 
@@ -622,11 +618,11 @@ BOOL MyH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
                *s1 = '\0';
 
        cd.call_reference               = GetCallReference();
                *s1 = '\0';
 
        cd.call_reference               = GetCallReference();
-       cd.call_token                   = (const char *)GetCallToken();
-       cd.call_source_aliases  = (const char *)sourceAliases;
-       cd.call_dest_alias              = (const char *)destAliases;
-       cd.call_source_e164             = (const char *)sourceE164;
-       cd.call_dest_e164               = (const char *)destE164;
+       cd.call_token                   = strdup((const char *)GetCallToken());
+       cd.call_source_aliases          = strdup((const char *)sourceAliases);
+       cd.call_dest_alias              = strdup((const char *)destAliases);
+       cd.call_source_e164             = strdup((const char *)sourceE164);
+       cd.call_dest_e164               = strdup((const char *)destE164);
 
        int res = on_outgoing_call(cd); 
                
 
        int res = on_outgoing_call(cd);