Merge branch 'development'
[NeonServV5.git] / src / ModeNode.c
index 7dc10f0b68eda98f0434c15a92623961e8581a31..f3579cd42b71654ae34d168eddec03bf6393b5c8 100644 (file)
@@ -1,4 +1,4 @@
-/* ModeNode.c - NeonServ v5.3
+/* ModeNode.c - NeonServ v5.6
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -19,6 +19,7 @@
 #include "ChanUser.h"
 #include "UserNode.h"
 #include "BanNode.h"
+#include "log.h"
 
 static int modes_with_strarg, modes_with_intarg, modes_count;
 
@@ -77,7 +78,7 @@ struct ModeNode *createModeNode(struct ChanNode *chan) {
     struct ModeNode *modes = malloc(sizeof(*modes));
     if (!modes)
     {
-        perror("malloc() failed");
+        printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
         return NULL;
     }
     modes->chan = chan;
@@ -284,7 +285,7 @@ int parseMode(struct ModeNode* modes, int add, char mode, char *param) {
         modes->modes &= ~modeOpt[0];
         modes->allmodes |= modeOpt[0];
         if(MODE_TYPE == CHANNEL_MODE_TYPE_B) {
-            if(!param) return 0;
+            if(!param && !(modeOpt[2] & CHANNEL_MODE_KEY)) return 0;
             if(MODE_VALUE == CHANNEL_MODE_VALUE_STRING) {
                 free(modes->mode_str_args[MODE_VALUE_INDEX]);
                 modes->mode_str_args[MODE_VALUE_INDEX] = NULL;