diff options
| author | Paul Eggert | 2017-07-09 16:04:02 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-07-09 16:05:13 -0700 |
| commit | 083940a93df17c6e50d6523e30d56ca3d179f688 (patch) | |
| tree | 7192d741b6d66943c4f4fd38436aaf8960e6299a /test/src | |
| parent | ce6773aad5c71f6c486244a6fc9fcb69fc99784d (diff) | |
| download | emacs-083940a93df17c6e50d6523e30d56ca3d179f688.tar.gz emacs-083940a93df17c6e50d6523e30d56ca3d179f688.zip | |
Fix core dump in substitute-object-in-subtree
Without this fix, (substitute-object-in-subtree #0=(#0# 'a) 'a)
would dump core, since the C code would recurse indefinitely through
the infinite structure. This patch adds an argument to the function,
and renames it to lread--substitute-object-in-subtree as the function
is not general-purpose and should not be relied on by outside code.
See Bug#23660.
* src/intervals.c (traverse_intervals_noorder): ARG is now void *,
not Lisp_Object, so that callers need not cons unnecessarily.
All callers changed. Also, remove related #if-0 code that was
“temporary” in the early 1990s and has not been compilable for
some time.
* src/lread.c (struct subst): New type, for substitution closure data.
(seen_list): Remove this static var, as this info is now part of
struct subst. All uses removed.
(Flread__substitute_object_in_subtree): Rename from
Fsubstitute_object_in_subtree, and give it a 3rd arg so that it
doesn’t dump core when called from the top level with an
already-cyclic structure. All callers changed.
(SUBSTITUTE): Remove. All callers expanded and then simplified.
(substitute_object_recurse): Take a single argument SUBST rather
than a pair OBJECT and PLACEHOLDER, so that its address can be
passed around as part of a closure; this avoids the need for an
AUTO_CONS call. All callers changed. If the COMPLETED component
is t, treat every subobject as potentially circular.
(substitute_in_interval): Take a struct subst * rather than a
Lisp_Object, for the closure data. All callers changed.
* test/src/lread-tests.el (lread-lread--substitute-object-in-subtree):
New test, to check that the core dump does not reoccur.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/lread-tests.el | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 98cbb6a301d..a0a317feeeb 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -164,4 +164,10 @@ literals (Bug#20852)." | |||
| 164 | (concat (format-message "Loading `%s': " file-name) | 164 | (concat (format-message "Loading `%s': " file-name) |
| 165 | "old-style backquotes detected!"))))) | 165 | "old-style backquotes detected!"))))) |
| 166 | 166 | ||
| 167 | (ert-deftest lread-lread--substitute-object-in-subtree () | ||
| 168 | (let ((x (cons 0 1))) | ||
| 169 | (setcar x x) | ||
| 170 | (lread--substitute-object-in-subtree x 1 t) | ||
| 171 | (should (eq x (cdr x))))) | ||
| 172 | |||
| 167 | ;;; lread-tests.el ends here | 173 | ;;; lread-tests.el ends here |