From 54f5c32fe2b9f96510a00aae553494496b90e243 Mon Sep 17 00:00:00 2001 From: pk910 Date: Mon, 27 Aug 2012 06:25:44 +0200 Subject: [PATCH] fixed crash caused by startup reload event --- src/IRCEvents.c | 7 +++++-- src/main.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/IRCEvents.c b/src/IRCEvents.c index b4eba22..a2b7717 100644 --- a/src/IRCEvents.c +++ b/src/IRCEvents.c @@ -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)) diff --git a/src/main.c b/src/main.c index 3bef6ee..17b8258 100644 --- a/src/main.c +++ b/src/main.c @@ -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); -- 2.20.1