diff options
author | Richard M. Stallman <rms@gnu.org> | 1997-07-12 06:51:51 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1997-07-12 06:51:51 +0000 |
commit | 8a0eb0e610780bbac703dc22ae346cc2e14be885 (patch) | |
tree | 85752e55bdd65158b7aaac8ef35f6f1bc39eb973 /src/filelock.c | |
parent | c024ed6b53d837ff15ca806994153fc632de4650 (diff) | |
download | emacs-8a0eb0e610780bbac703dc22ae346cc2e14be885.tar.gz |
(lock_file_1): Don't crash if Fuser_login_name or
Fsystem_name don't return strings.
(current_lock_owner): Likewise.
Diffstat (limited to 'src/filelock.c')
-rw-r--r-- | src/filelock.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/filelock.c b/src/filelock.c index d92e0476bad..5000f87a615 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -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. */ |