Do not call silc_client_stop before silc_client_init has been
authorPekka Riikonen <priikone@silcnet.org>
Wed, 23 May 2007 20:28:03 +0000 (20:28 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 23 May 2007 20:28:03 +0000 (20:28 +0000)
called.  Fixed crash in SILC Plugin.

CHANGES
apps/irssi/src/silc/core/silc-core.c

diff --git a/CHANGES b/CHANGES
index fe2adfaff622ebe48c4f6a50e58868d5ad44a020..d2da41ea9e34b7819e9807545d5db5d33ded7f84 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,10 @@ Wed May 23 23:21:03 EEST 2007  Pekka Riikonen <priikone@silcnet.org>
          nicklist (/NAMES etc).  Affected file is
          apps/irssi/src/silc/core/client_ops.c.
 
+       * Fixed SILC Plugin crash when stopping client library before
+         it has been started.  Affected file is
+         apps/irssi/src/silc/core/silc-core.c.
+
 Tue May 22 17:18:54 EEST 2007  Pekka Riikonen <priikone@silcnet.org>
 
        * For SILC Client and SILC Server check for 1.1 Toolkit
index 3084f7407760da9fe1c0c73b154f7c109dd7d322..3f7677f265a1064ac367b09a249bdf563b4a8dbe 100644 (file)
@@ -51,6 +51,7 @@ static int init_failed = 0;
 #endif
 
 static int idletag = -1;
+static int running = 0;
 
 /* SILC Client */
 SilcClient silc_client = NULL;
@@ -561,6 +562,7 @@ silc_stopped(SilcClient client, void *context)
 static void
 silc_running(SilcClient client, void *context)
 {
+  running = 1;
   SILC_LOG_DEBUG(("Client library is running"));
 }
 
@@ -791,11 +793,12 @@ void silc_core_deinit(void)
   if (idletag != -1)
     g_source_remove(idletag);
 
-  int stopped = 0;
-  silc_client_stop(silc_client, silc_stopped, &stopped);
-
-  while (!stopped)
-    silc_client_run_one(silc_client);
+  if (running) {
+    int stopped = 0;
+    silc_client_stop(silc_client, silc_stopped, &stopped);
+    while (!stopped)
+      silc_client_run_one(silc_client);
+  }
 
   if (opt_hostname)
     silc_free(opt_hostname);