diff --git a/src/libcharon/sa/ike_sa_manager.c b/src/libcharon/sa/ike_sa_manager.c index 9fec03348..b6321cf16 100644 --- a/src/libcharon/sa/ike_sa_manager.c +++ b/src/libcharon/sa/ike_sa_manager.c @@ -1501,8 +1501,11 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*, if (!this->reuse_ikesa && peer_cfg->get_ike_version(peer_cfg) != IKEV1) { /* IKE_SA reuse disabled by config (not possible for IKEv1) */ ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE); - ike_sa->set_peer_cfg(ike_sa, peer_cfg); - checkout_new(this, ike_sa); + if (ike_sa) + { + ike_sa->set_peer_cfg(ike_sa, peer_cfg); + checkout_new(this, ike_sa); + } charon->bus->set_sa(charon->bus, ike_sa); goto out; } @@ -1573,8 +1576,11 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*, if (!ike_sa) { ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE); - ike_sa->set_peer_cfg(ike_sa, peer_cfg); - checkout_new(this, ike_sa); + if (ike_sa) + { + ike_sa->set_peer_cfg(ike_sa, peer_cfg); + checkout_new(this, ike_sa); + } } charon->bus->set_sa(charon->bus, ike_sa);