lock() didn't set user-defined locks properly
authorAri Johnson <ari@cobramush.org>
Tue, 20 Feb 2007 15:48:28 +0000 (15:48 +0000)
committerAri Johnson <ari@cobramush.org>
Tue, 20 Feb 2007 15:48:28 +0000 (15:48 +0000)
src/fundb.c
src/lock.c

index d6214fe9e1b58d152633d6512a716286fc82c8cf..ad2521a43a162bd6d9dc56cd159db967eb36d678 100644 (file)
@@ -1076,14 +1076,17 @@ get_locktype(str)
 FUNCTION(fun_lock)
 {
   dbref it;
-  char *p;
-  lock_type ltype;
+  char *ltype = NULL;
+  lock_type real_ltype;
 
-  if ((p = strchr(args[0], '/')))
-    *p++ = '\0';
+  if ((ltype = strchr(args[0], '/'))) {
+    *ltypep++ = '\0';
+    upcasestr(ltype);
+  }
+
+  real_ltype = get_locktype(ltype);
 
   it = match_thing(executor, args[0]);
-  ltype = get_locktype(p);
 
   if (nargs == 2) {
     if (!command_check_byname(executor, "@lock") || fun->flags & FN_NOSIDEFX) {
@@ -1097,9 +1100,10 @@ FUNCTION(fun_lock)
       return;
     }
   }
-  if (GoodObject(it) && (ltype != NULL)
-      && Can_Read_Lock(executor, it, ltype)) {
-    safe_str(unparse_boolexp(executor, getlock(it, ltype), UB_DBREF), buff, bp);
+  if (GoodObject(it) && (real_ltype != NULL)
+      && Can_Read_Lock(executor, it, real_ltype)) {
+    safe_str(unparse_boolexp(executor, getlock(it, real_ltype), UB_DBREF),
+            buff, bp);
     return;
   }
   safe_str("#-1", buff, bp);
index 466934ba923e2bd993528bcb6452d287f27be6db..c22d76e77eb6786e80071d1e15f12b27d55d0f42 100644 (file)
@@ -763,9 +763,12 @@ do_lock(dbref player, const char *name, const char *keyname, lock_type type)
           lmbuf[strlen(lmbuf)+1] = '\0';
           set_lmod(thing, lmbuf);
        }
-      } else
+      } else {
        notify(player, T("Permission denied."));
-    }
+       free_boolexp(key);
+      }
+    } else
+      free_boolexp(key);
   }
 }