fixed clone/destroy behavior when not using CAs
authorMartin Willi <martin@strongswan.org>
Fri, 9 Jun 2006 07:40:40 +0000 (07:40 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 9 Jun 2006 07:40:40 +0000 (07:40 -0000)
src/charon/config/policies/policy.c

index f30d596..4e238a3 100644 (file)
@@ -340,9 +340,15 @@ static policy_t *clone(private_policy_t *this)
        traffic_selector_t *ts;
        
        /* clone the certification authorities */
-       clone->my_ca = this->my_ca->clone(this->my_ca);
-       clone->other_ca = this->other_ca->clone(this->other_ca);
-
+       if (this->my_ca)
+       {
+               clone->my_ca = this->my_ca->clone(this->my_ca);
+       }
+       if (this->other_ca)
+       {
+               clone->other_ca = this->other_ca->clone(this->other_ca);
+       }
+       
        /* clone all proposals */
        iterator = this->proposals->create_iterator(this->proposals, TRUE);
        while (iterator->has_next(iterator))
@@ -407,8 +413,14 @@ static status_t destroy(private_policy_t *this)
        this->other_ts->destroy(this->other_ts);
        
        /* delete certification authorities */
-       this->my_ca->destroy(this->my_ca);
-       this->other_ca->destroy(this->other_ca);
+       if (this->my_ca)
+       {
+               this->my_ca->destroy(this->my_ca);
+       }
+       if (this->other_ca)
+       {
+               this->other_ca->destroy(this->other_ca);
+       }
 
        /* delete ids */
        this->my_id->destroy(this->my_id);