More client library rewrites (added rekey)
[silc.git] / lib / silcclient / command.c
index b1d233fc8c1a7f3f0ac6d4ec48104ed7366e8ae1..7ffa52fa36f471a90d84ecfcb6f5014447a41bfb 100644 (file)
@@ -352,6 +352,12 @@ void silc_client_command_free(SilcClientCommandContext cmd)
   SilcClientCommandReplyCallback cb;
   int i;
 
+  /* If command is running, finish it.  Destructor will free the context. */
+  if (silc_fsm_is_started(&cmd->thread)) {
+    silc_fsm_finish(&cmd->thread);
+    return;
+  }
+
   for (i = 0; i < cmd->argc; i++)
     silc_free(cmd->argv[i]);
   silc_free(cmd->argv);