Commit 662c2ef2 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(lock_file_1): Don't crash if Fuser_login_name or

Fsystem_name don't return strings.
(current_lock_owner): Likewise.
parent 39ce6952
......@@ -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. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment