fixed two other memory leaks
authorTobias Brunner <tobias@strongswan.org>
Thu, 3 Apr 2008 15:13:25 +0000 (15:13 -0000)
committerTobias Brunner <tobias@strongswan.org>
Thu, 3 Apr 2008 15:13:25 +0000 (15:13 -0000)
src/charon/config/peer_cfg.c
src/charon/config/peer_cfg.h
src/charon/processing/jobs/initiate_mediation_job.c
src/charon/sa/ike_sa.c

index 9e11f88..d85935c 100644 (file)
@@ -449,11 +449,7 @@ static bool is_mediation(private_peer_cfg_t *this)
  */
 static peer_cfg_t* get_mediated_by(private_peer_cfg_t *this)
 {
-       if (this->mediated_by) {
-               this->mediated_by->get_ref(this->mediated_by);
-               return this->mediated_by;
-       }
-       return NULL;
+       return this->mediated_by;
 }
 
 /**
index e8c0e60..43bcb8e 100644 (file)
@@ -303,7 +303,7 @@ struct peer_cfg_t {
        /**
         * Get peer_cfg of the connection this one is mediated through.
         * 
-        * @return                              reference to peer_cfg of the mediation connection
+        * @return                              the peer_cfg of the mediation connection
         */
        peer_cfg_t* (*get_mediated_by) (peer_cfg_t *this);
        
index 3799420..483420b 100644 (file)
@@ -94,6 +94,7 @@ static void initiate(private_initiate_mediation_job_t *this)
                charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
                
                mediation_cfg = mediated_cfg->get_mediated_by(mediated_cfg);
+               mediation_cfg->get_ref(mediation_cfg);
                
                if (charon->connect_manager->check_and_register(charon->connect_manager,
                                mediation_cfg->get_my_id(mediation_cfg),
index 58a3445..1420079 100644 (file)
@@ -396,6 +396,7 @@ static peer_cfg_t* get_peer_cfg(private_ike_sa_t *this)
  */
 static void set_peer_cfg(private_ike_sa_t *this, peer_cfg_t *peer_cfg)
 {
+       DESTROY_IF(this->peer_cfg);
        peer_cfg->get_ref(peer_cfg);
        this->peer_cfg = peer_cfg;
 
@@ -1007,8 +1008,8 @@ static status_t initiate_mediation(private_ike_sa_t *this, peer_cfg_t *mediated_
 static status_t initiate_mediated(private_ike_sa_t *this, host_t *me, host_t *other,
                linked_list_t *childs, chunk_t connect_id)
 {
-       this->my_host = me->clone(me);
-       this->other_host = other->clone(other);
+       set_my_host(this, me->clone(me));
+       set_other_host(this, other->clone(other));
        this->connect_id = chunk_clone(connect_id);
        
        task_t *task;