fixed crash caused by startup reload event
authorpk910 <philipp@zoelle1.de>
Mon, 27 Aug 2012 04:25:44 +0000 (06:25 +0200)
committerpk910 <philipp@zoelle1.de>
Mon, 27 Aug 2012 04:25:44 +0000 (06:25 +0200)
src/IRCEvents.c
src/main.c

index b4eba22e0fcf2eab39747cd18796bc9c81c2890a..a2b7717c7488e7cd9e9909fcd145ee34d06d47dc 100644 (file)
@@ -28,7 +28,7 @@ struct binding {
     struct binding *next;
 };
 
-static void **binds;
+static void **binds = NULL;
 #define BIND_TYPE_JOIN       0
 #define BIND_TYPE_NICK       1
 #define BIND_TYPE_PART       2
@@ -53,6 +53,8 @@ static void **binds;
 #define TOTAL_BIND_TYPES     20
 
 void init_bind() {
+    if(binds)
+        return;
     binds = calloc(TOTAL_BIND_TYPES, sizeof(*binds));
 }
 
@@ -66,6 +68,7 @@ void free_bind() {
         }
     }
     free(binds);
+    binds = NULL;
 }
 
 void unregister_module_events(int module_id) {
@@ -225,4 +228,4 @@ FUNC_EVENT(freechan, freechan_func_t, BIND_TYPE_FREECHAN, (struct ChanNode *chan
 
 FUNC_BIND(reload, reload_func_t, BIND_TYPE_RELOAD)
 FUNC_UNBIND(reload, reload_func_t, BIND_TYPE_RELOAD)
-FUNC_EVENT(reload, reload_func_t, BIND_TYPE_RELOAD, (int initialization), (initialization))
\ No newline at end of file
+FUNC_EVENT(reload, reload_func_t, BIND_TYPE_RELOAD, (int initialization), (initialization))
index 3bef6eeb08ca917c821ae6240b5c4c2d5e254264..17b8258c5110fd17760cce6313f4d5a2154d11d8 100644 (file)
@@ -209,6 +209,7 @@ int main(int argc, char *argv[]) {
         fprintf(stderr, "Unable to load " CONF_FILE "\n");
         exit(0);
     }
+    init_bind();
     event_reload(1);
     #if HAVE_THREADS
     THREAD_MUTEX_INIT(log_sync);