浏览代码

* Only remove key if it exists

Bryan Drewery 14 年之前
父节点
当前提交
492cdb5254
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      src/chanprog.c

+ 5 - 4
src/chanprog.c

@@ -949,12 +949,13 @@ void keyx(const bd::String &target) {
 
 void set_fish_key(char *target, char *key)
 {
-  fish_data_t* fishData = NULL;
-  fishData = FishKeys[target];
+  fish_data_t* fishData = FishKeys.contains(target) ? FishKeys[target] : NULL;
 
   if (!key || !key[0]) { //remove key
-    FishKeys.remove(target);
-    delete fishData;
+    if (fishData) {
+      FishKeys.remove(target);
+      delete fishData;
+    }
   } else { //set key
     fishData = new fish_data_t;