fixed a use-after-free bug in dpd_timeout()
[strongswan.git] / src / pluto / state.c
index 80c3156..d1587a1 100644 (file)
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  *
- * RCSID $Id: state.c,v 1.13 2006/04/29 18:16:02 as Exp $
+ * RCSID $Id$
  */
 
 #include <stdio.h>
@@ -464,12 +464,7 @@ delete_states_by_connection(struct connection *c, bool relations)
        passert(sr->routing != RT_ROUTED_TUNNEL);
        sr = sr->next;
     }
-
-    if (ck == CK_INSTANCE)
-    {
-       c->kind = ck;
-       delete_connection(c, relations);
-    }
+    c->kind = ck;
 }
 
 /* Walk through the state table, and delete each state whose phase 1 (IKE)
@@ -506,6 +501,8 @@ delete_states_by_peer(ip_address *peer)
                         , peerstr
                         , c->name);
                    delete_states_by_connection(c, TRUE);
+                   if (c->kind == CK_INSTANCE)
+                       delete_connection(c, TRUE);
                    break;      /* can only delete it once */
                }
            }