diff options
| author | Lars Ingebrigtsen | 2021-07-07 22:15:42 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-07-07 22:15:47 +0200 |
| commit | e762864b9d501cfbc15fd20f403fc435bbdc580e (patch) | |
| tree | a4dfe53f2b951256dd59e816eedec2ba934b79d4 | |
| parent | fadfc55db1179712049077b2c195669687bf54dd (diff) | |
| download | emacs-e762864b9d501cfbc15fd20f403fc435bbdc580e.tar.gz 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.
| -rw-r--r-- | src/filelock.c | 11 |
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) | |||
| 622 | static Lisp_Object | 622 | static Lisp_Object |
| 623 | make_lock_file_name (Lisp_Object fn) | 623 | make_lock_file_name (Lisp_Object fn) |
| 624 | { | 624 | { |
| 625 | return call1 (intern ("make-lock-file-name"), Fexpand_file_name (fn, Qnil)); | 625 | Lisp_Object func = intern ("make-lock-file-name"); |
| 626 | if (NILP (Fboundp (func))) | ||
| 627 | return Qnil; | ||
| 628 | return call1 (func, Fexpand_file_name (fn, Qnil)); | ||
| 626 | } | 629 | } |
| 627 | 630 | ||
| 628 | /* lock_file locks file FN, | 631 | /* lock_file locks file FN, |
| @@ -663,6 +666,8 @@ lock_file (Lisp_Object fn) | |||
| 663 | } | 666 | } |
| 664 | 667 | ||
| 665 | Lisp_Object lock_filename = make_lock_file_name (fn); | 668 | Lisp_Object lock_filename = make_lock_file_name (fn); |
| 669 | if (NILP (lock_filename)) | ||
| 670 | return; | ||
| 666 | char *lfname = SSDATA (ENCODE_FILE (lock_filename)); | 671 | char *lfname = SSDATA (ENCODE_FILE (lock_filename)); |
| 667 | 672 | ||
| 668 | /* See if this file is visited and has changed on disk since it was | 673 | /* See if this file is visited and has changed on disk since it was |
| @@ -715,6 +720,8 @@ unlock_file_body (Lisp_Object fn) | |||
| 715 | } | 720 | } |
| 716 | 721 | ||
| 717 | Lisp_Object lock_filename = make_lock_file_name (fn); | 722 | Lisp_Object lock_filename = make_lock_file_name (fn); |
| 723 | if (NILP (lock_filename)) | ||
| 724 | return Qnil; | ||
| 718 | lfname = SSDATA (ENCODE_FILE (lock_filename)); | 725 | lfname = SSDATA (ENCODE_FILE (lock_filename)); |
| 719 | 726 | ||
| 720 | int err = current_lock_owner (0, lfname); | 727 | 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. */) | |||
| 859 | } | 866 | } |
| 860 | 867 | ||
| 861 | Lisp_Object lock_filename = make_lock_file_name (filename); | 868 | Lisp_Object lock_filename = make_lock_file_name (filename); |
| 869 | if (NILP (lock_filename)) | ||
| 870 | return Qnil; | ||
| 862 | char *lfname = SSDATA (ENCODE_FILE (lock_filename)); | 871 | char *lfname = SSDATA (ENCODE_FILE (lock_filename)); |
| 863 | 872 | ||
| 864 | owner = current_lock_owner (&locker, lfname); | 873 | owner = current_lock_owner (&locker, lfname); |