diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-10-30 14:17:40 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-10-30 14:43:14 -0700 |
commit | 40ae02ff50a8f05660a7f9f234320875b6358c9d (patch) | |
tree | c5d4a135409445f1886cda3001bfa41472f8b3fb /test/src | |
parent | 94b8153eaa78e376e6ed8c2b04602edf3dadc007 (diff) | |
download | emacs-40ae02ff50a8f05660a7f9f234320875b6358c9d.tar.gz |
Fix fileio.c infloops on circular lists
Fix infinite loops in fileio.c when a circular list is the
value of after_insert_file_functions,
buffer-auto-save-file-format, buffer-file-format, or
write-region-annotate-functions.
* src/fileio.c (Finsert_file_contents, build_annotations):
Use FOR_EACH_TAIL to avoid infloop on circular lists.
(build_annotations): Use an EMACS_INT, not an int, to count
nesting level.
* test/src/fileio-tests.el:
(fileio-tests--circular-after-insert-file-functions): New test.
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/fileio-tests.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 98d3d6be763..2225897af8c 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -147,3 +147,12 @@ Also check that an encoding error can appear in a symlink." (should (file-name-absolute-p (concat "~" user-login-name suffix)))) (unless (user-full-name "nosuchuser") (should (not (file-name-absolute-p (concat "~nosuchuser" suffix))))))) + +(ert-deftest fileio-tests--circular-after-insert-file-functions () + "Test after-insert-file-functions as a circular list." + (let ((f (make-temp-file "fileio")) + (after-insert-file-functions (list 'identity))) + (setcdr after-insert-file-functions after-insert-file-functions) + (write-region "hello\n" nil f nil 'silent) + (should-error (insert-file-contents f) :type 'circular-list) + (delete-file f))) |