]> git.eshelyaron.com Git - emacs.git/commitdiff
(lock_file_1): Don't crash if Fuser_login_name or
authorRichard M. Stallman <rms@gnu.org>
Sat, 12 Jul 1997 06:51:51 +0000 (06:51 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 12 Jul 1997 06:51:51 +0000 (06:51 +0000)
Fsystem_name don't return strings.
(current_lock_owner): Likewise.

src/filelock.c

index d92e0476bad87d552777891a3d32ab86c613d0a3..5000f87a6151bb6f68561fd48d83efb009a754a6 100644 (file)
@@ -133,10 +133,20 @@ lock_file_1 (lfname, force)
      int force;
 {
   register int err;
-  char *user_name = (char *) XSTRING (Fuser_login_name (Qnil))->data;
-  char *host_name = (char *) XSTRING (Fsystem_name ())->data;
-  char *lock_info_str = alloca (strlen (user_name) + strlen (host_name)
-                                + LOCK_PID_MAX + 5);
+  char *user_name;
+  char *host_name;
+  char *lock_info_str;
+
+  if (STRINGP (Fuser_login_name (Qnil)))
+    user_name = XSTRING (Fuser_login_name (Qnil))->data;
+  else
+    user_name = "";
+  if (STRINGP (Fsystem_name ()))
+    host_name = XSTRING (Fsystem_name ())->data;
+  else
+    host_name = "";
+  lock_info_str = alloca (strlen (user_name) + strlen (host_name)
+                         + LOCK_PID_MAX + 5);
 
   sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
            (unsigned long) getpid ());
@@ -225,7 +235,8 @@ current_lock_owner (owner, lfname)
   xfree (lfinfo);
   
   /* On current host?  */
-  if (strcmp (owner->host, XSTRING (Fsystem_name ())->data) == 0)
+  if (STRINGP (Fsystem_name ())
+      && strcmp (owner->host, XSTRING (Fsystem_name ())->data) == 0)
     {
       if (owner->pid == getpid ())
         ret = 2; /* We own it.  */