emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e762864: Make make_lock_file_name more robust


From: Lars Ingebrigtsen
Subject: master e762864: Make make_lock_file_name more robust
Date: Wed, 7 Jul 2021 16:15:52 -0400 (EDT)

branch: master
commit e762864b9d501cfbc15fd20f403fc435bbdc580e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 src/filelock.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/filelock.c b/src/filelock.c
index 99803cc..20916ac 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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]