diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2009-09-11 16:46:08 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2009-09-11 16:46:08 +0000 |
commit | 78012bd2ec6d3d152c420d3a0b091956b9814780 (patch) | |
tree | 77f1f2e93027d3de2e401b8277ee65198d7fd414 | |
parent | 7e0aa125bcf84c423a261a84970a0402764c353a (diff) | |
download | emacs-78012bd2ec6d3d152c420d3a0b091956b9814780.tar.gz emacs-78012bd2ec6d3d152c420d3a0b091956b9814780.tar.bz2 emacs-78012bd2ec6d3d152c420d3a0b091956b9814780.zip |
(display_mode_element): Detect cycles.
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/xdisp.c | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index de2c7c30f44..d06faa3d711 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-09-11 Andreas Schwab <schwab@linux-m68k.org> + + * xdisp.c (display_mode_element): Detect cycles. + 2009-09-11 Stefan Monnier <monnier@iro.umontreal.ca> * keymap.c (where_is_internal): Don't erroneously return nil right after diff --git a/src/xdisp.c b/src/xdisp.c index 9108ab6bf72..58a077fe5f5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -17750,14 +17750,10 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) } else if (STRINGP (car) || CONSP (car)) { - register int limit = 5000; - /* Limit is to protect against circular lists. - The limit used to be 50, but if you use enough minor modes, - minor-mode-alist will easily grow past 50. Circular lists - are rather unlikely, so it's better for the limit to be - "too large" rather than "too small". */ + Lisp_Object halftail = elt; + int len = 0; + while (CONSP (elt) - && --limit > 0 && (precision <= 0 || n < precision)) { n += display_mode_element (it, depth, @@ -17769,6 +17765,12 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) precision - n, XCAR (elt), props, risky); elt = XCDR (elt); + len++; + if ((len & 1) == 0) + halftail = XCDR (halftail); + /* Check for cycle. */ + if (EQ (halftail, elt)) + break; } } } |