fixed crash caused by startup reload event
[NeonServV5.git] / src / IRCEvents.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))