summaryrefslogtreecommitdiff
path: root/src/filelock.c
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-07-07 22:15:42 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-07-07 22:15:47 +0200
commite762864b9d501cfbc15fd20f403fc435bbdc580e (patch)
treea4dfe53f2b951256dd59e816eedec2ba934b79d4 /src/filelock.c
parentfadfc55db1179712049077b2c195669687bf54dd (diff)
downloademacs-e762864b9d501cfbc15fd20f403fc435bbdc580e.tar.gz
emacs-e762864b9d501cfbc15fd20f403fc435bbdc580e.tar.bz2
emacs-e762864b9d501cfbc15fd20f403fc435bbdc580e.zip
Make make_lock_file_name more robust
* src/filelock.c (make_lock_file_name): Protect against the make-lock-file-name not being defined. (lock_file, unlock_file_body, Ffile_locked_p): Return early if not defined.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 99803ccff78..20916ace50d 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -622,7 +622,10 @@ lock_if_free (lock_info_type *clasher, char *lfname)
static Lisp_Object
make_lock_file_name (Lisp_Object fn)
{
- return call1 (intern ("make-lock-file-name"), Fexpand_file_name (fn, Qnil));
+ Lisp_Object func = intern ("make-lock-file-name");
+ if (NILP (Fboundp (func)))
+ return Qnil;
+ return call1 (func, Fexpand_file_name (fn, Qnil));
}
/* lock_file locks file FN,
@@ -663,6 +666,8 @@ lock_file (Lisp_Object fn)
}
Lisp_Object lock_filename = make_lock_file_name (fn);
+ if (NILP (lock_filename))
+ return;
char *lfname = SSDATA (ENCODE_FILE (lock_filename));
/* See if this file is visited and has changed on disk since it was
@@ -715,6 +720,8 @@ unlock_file_body (Lisp_Object fn)
}
Lisp_Object lock_filename = make_lock_file_name (fn);
+ if (NILP (lock_filename))
+ return Qnil;
lfname = SSDATA (ENCODE_FILE (lock_filename));
int err = current_lock_owner (0, lfname);
@@ -859,6 +866,8 @@ t if it is locked by you, else a string saying which user has locked it. */)
}
Lisp_Object lock_filename = make_lock_file_name (filename);
+ if (NILP (lock_filename))
+ return Qnil;
char *lfname = SSDATA (ENCODE_FILE (lock_filename));
owner = current_lock_owner (&locker, lfname);