changeset 18755:f2c1ffb0778a

(lock_file_1): Don't crash if Fuser_login_name or Fsystem_name don't return strings. (current_lock_owner): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Sat, 12 Jul 1997 06:51:51 +0000
parents f21dd94faebc
children 751f531e5a20
files src/filelock.c
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/filelock.c	Sat Jul 12 06:49:45 1997 +0000
+++ b/src/filelock.c	Sat Jul 12 06:51:51 1997 +0000
@@ -133,10 +133,20 @@
      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 @@
   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.  */