diff options
| author | Paul Eggert | 2019-10-30 14:17:40 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-10-30 14:43:14 -0700 |
| commit | 40ae02ff50a8f05660a7f9f234320875b6358c9d (patch) | |
| tree | c5d4a135409445f1886cda3001bfa41472f8b3fb /test/src | |
| parent | 94b8153eaa78e376e6ed8c2b04602edf3dadc007 (diff) | |
| download | emacs-40ae02ff50a8f05660a7f9f234320875b6358c9d.tar.gz emacs-40ae02ff50a8f05660a7f9f234320875b6358c9d.zip | |
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." | |||
| 147 | (should (file-name-absolute-p (concat "~" user-login-name suffix)))) | 147 | (should (file-name-absolute-p (concat "~" user-login-name suffix)))) |
| 148 | (unless (user-full-name "nosuchuser") | 148 | (unless (user-full-name "nosuchuser") |
| 149 | (should (not (file-name-absolute-p (concat "~nosuchuser" suffix))))))) | 149 | (should (not (file-name-absolute-p (concat "~nosuchuser" suffix))))))) |
| 150 | |||
| 151 | (ert-deftest fileio-tests--circular-after-insert-file-functions () | ||
| 152 | "Test after-insert-file-functions as a circular list." | ||
| 153 | (let ((f (make-temp-file "fileio")) | ||
| 154 | (after-insert-file-functions (list 'identity))) | ||
| 155 | (setcdr after-insert-file-functions after-insert-file-functions) | ||
| 156 | (write-region "hello\n" nil f nil 'silent) | ||
| 157 | (should-error (insert-file-contents f) :type 'circular-list) | ||
| 158 | (delete-file f))) | ||