]> git.eshelyaron.com Git - emacs.git/commitdiff
* Guard against trying to rename files into eln sys directory
authorAndrea Corallo <akrl@sdf.org>
Thu, 10 Sep 2020 07:59:29 +0000 (09:59 +0200)
committerAndrea Corallo <akrl@sdf.org>
Thu, 10 Sep 2020 08:55:25 +0000 (10:55 +0200)
* src/comp.c (file_in_eln_sys_dir): New function.
(Fnative_elisp_load): Make use of.

src/comp.c

index 4550833a6a2120d96cfa6833c28347966b9b8851..d7966d42221c677bb5ef444d7fff7334843e4506 100644 (file)
@@ -4912,6 +4912,18 @@ DEFUN ("comp--late-register-subr", Fcomp__late_register_subr,
   return Qnil;
 }
 
+static bool
+file_in_eln_sys_dir (Lisp_Object filename)
+{
+  Lisp_Object eln_sys_dir = Qnil;
+  Lisp_Object tmp = Vcomp_eln_load_path;
+  FOR_EACH_TAIL (tmp)
+    eln_sys_dir = XCAR (tmp);
+  return !NILP (Fstring_match (Fregexp_quote (Fexpand_file_name (eln_sys_dir,
+                                                                Qnil)),
+                              Fexpand_file_name (filename, Qnil), Qnil));
+}
+
 /* Load related routines.  */
 DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 2, 0,
        doc: /* Load native elisp code FILENAME.
@@ -4926,6 +4938,7 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 2, 0,
   struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit ();
 
   if (!NILP (Fgethash (filename, all_loaded_comp_units_h, Qnil))
+      && !file_in_eln_sys_dir (filename)
       && !NILP (Ffile_writable_p (filename)))
     {
       /* If in this session there was ever a file loaded with this