Change order of destroy/get_ref function calls
authorThomas Egerer <thomas.egerer@secunet.com>
Fri, 4 Nov 2011 08:24:51 +0000 (09:24 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 4 Nov 2011 10:11:17 +0000 (11:11 +0100)
Since DESTROY_IF might destroy the peer_cfg, a get_ref on a freed object
is subject to fail.

src/libcharon/sa/ike_sa.c

index 6536acf..75868ab 100644 (file)
@@ -349,8 +349,8 @@ METHOD(ike_sa_t, get_peer_cfg, peer_cfg_t*,
 METHOD(ike_sa_t, set_peer_cfg, void,
        private_ike_sa_t *this, peer_cfg_t *peer_cfg)
 {
-       DESTROY_IF(this->peer_cfg);
        peer_cfg->get_ref(peer_cfg);
+       DESTROY_IF(this->peer_cfg);
        this->peer_cfg = peer_cfg;
 
        if (this->ike_cfg == NULL)