diff options
| author | Chong Yidong | 2010-12-06 01:54:52 -0500 |
|---|---|---|
| committer | Chong Yidong | 2010-12-06 01:54:52 -0500 |
| commit | d8b2a96214c9b53ab914901fdde71f5b0a931678 (patch) | |
| tree | b460510f4b2cc856332affb7c7ae2796d04acdb4 /src | |
| parent | 0afb6242c77237cd2cc1f0e623b08e20488c5b74 (diff) | |
| download | emacs-d8b2a96214c9b53ab914901fdde71f5b0a931678.tar.gz emacs-d8b2a96214c9b53ab914901fdde71f5b0a931678.zip | |
Fix crash with invisible text and overlays (Bug#7016).
* src/dispextern.h (struct it): New member overlay_strings_charpos.
* src/xdisp.c (next_overlay_string, load_overlay_strings): Record the
charpos where we computed n_overlay_strings.
(next_overlay_string): Load overlay strings at recorded position,
which may not be the same as the iterator's charpos (Bug#7016).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/dispextern.h | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 10 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d10b5d194a9..3293ec08da5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2010-12-06 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * dispextern.h (struct it): New member overlay_strings_charpos. | ||
| 4 | |||
| 5 | * xdisp.c (next_overlay_string, load_overlay_strings): Record the | ||
| 6 | charpos where we computed n_overlay_strings. | ||
| 7 | (next_overlay_string): Load overlay strings at recorded position, | ||
| 8 | which may not be the same as the iterator's charpos (Bug#7016). | ||
| 9 | |||
| 1 | 2010-12-05 Jan Djärv <jan.h.d@swipnet.se> | 10 | 2010-12-05 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 11 | ||
| 3 | * nsterm.m (ns_dumpglyphs_image): If drawing cursor, fill background | 12 | * nsterm.m (ns_dumpglyphs_image): If drawing cursor, fill background |
diff --git a/src/dispextern.h b/src/dispextern.h index bc34aec2dd5..b43565739ea 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1989,6 +1989,12 @@ struct it | |||
| 1989 | OVERLAY_STRING_CHUNK_SIZE. */ | 1989 | OVERLAY_STRING_CHUNK_SIZE. */ |
| 1990 | int n_overlay_strings; | 1990 | int n_overlay_strings; |
| 1991 | 1991 | ||
| 1992 | /* The charpos where n_overlay_strings was calculated. This should | ||
| 1993 | be set at the same time as n_overlay_strings. It is needed | ||
| 1994 | because we show before-strings at the start of invisible text; | ||
| 1995 | see handle_invisible_prop in xdisp.c. */ | ||
| 1996 | int overlay_strings_charpos; | ||
| 1997 | |||
| 1992 | /* Vector of overlays to process. Overlay strings are processed | 1998 | /* Vector of overlays to process. Overlay strings are processed |
| 1993 | OVERLAY_STRING_CHUNK_SIZE at a time. */ | 1999 | OVERLAY_STRING_CHUNK_SIZE at a time. */ |
| 1994 | #define OVERLAY_STRING_CHUNK_SIZE 16 | 2000 | #define OVERLAY_STRING_CHUNK_SIZE 16 |
diff --git a/src/xdisp.c b/src/xdisp.c index dbe3e443c67..161e2b1cc4d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -4717,6 +4717,7 @@ next_overlay_string (it) | |||
| 4717 | && it->stop_charpos <= it->end_charpos)); | 4717 | && it->stop_charpos <= it->end_charpos)); |
| 4718 | it->current.overlay_string_index = -1; | 4718 | it->current.overlay_string_index = -1; |
| 4719 | it->n_overlay_strings = 0; | 4719 | it->n_overlay_strings = 0; |
| 4720 | it->overlay_strings_charpos = -1; | ||
| 4720 | 4721 | ||
| 4721 | /* If we're at the end of the buffer, record that we have | 4722 | /* If we're at the end of the buffer, record that we have |
| 4722 | processed the overlay strings there already, so that | 4723 | processed the overlay strings there already, so that |
| @@ -4729,11 +4730,13 @@ next_overlay_string (it) | |||
| 4729 | /* There are more overlay strings to process. If | 4730 | /* There are more overlay strings to process. If |
| 4730 | IT->current.overlay_string_index has advanced to a position | 4731 | IT->current.overlay_string_index has advanced to a position |
| 4731 | where we must load IT->overlay_strings with more strings, do | 4732 | where we must load IT->overlay_strings with more strings, do |
| 4732 | it. */ | 4733 | it. We must load at the IT->overlay_strings_charpos where |
| 4734 | IT->n_overlay_strings was originally computed; when invisible | ||
| 4735 | text is present, this might not be IT_CHARPOS (Bug#7016). */ | ||
| 4733 | int i = it->current.overlay_string_index % OVERLAY_STRING_CHUNK_SIZE; | 4736 | int i = it->current.overlay_string_index % OVERLAY_STRING_CHUNK_SIZE; |
| 4734 | 4737 | ||
| 4735 | if (it->current.overlay_string_index && i == 0) | 4738 | if (it->current.overlay_string_index && i == 0) |
| 4736 | load_overlay_strings (it, 0); | 4739 | load_overlay_strings (it, it->overlay_strings_charpos); |
| 4737 | 4740 | ||
| 4738 | /* Initialize IT to deliver display elements from the overlay | 4741 | /* Initialize IT to deliver display elements from the overlay |
| 4739 | string. */ | 4742 | string. */ |
| @@ -4949,8 +4952,9 @@ load_overlay_strings (it, charpos) | |||
| 4949 | if (n > 1) | 4952 | if (n > 1) |
| 4950 | qsort (entries, n, sizeof *entries, compare_overlay_entries); | 4953 | qsort (entries, n, sizeof *entries, compare_overlay_entries); |
| 4951 | 4954 | ||
| 4952 | /* Record the total number of strings to process. */ | 4955 | /* Record number of overlay strings, and where we computed it. */ |
| 4953 | it->n_overlay_strings = n; | 4956 | it->n_overlay_strings = n; |
| 4957 | it->overlay_strings_charpos = charpos; | ||
| 4954 | 4958 | ||
| 4955 | /* IT->current.overlay_string_index is the number of overlay strings | 4959 | /* IT->current.overlay_string_index is the number of overlay strings |
| 4956 | that have already been consumed by IT. Copy some of the | 4960 | that have already been consumed by IT. Copy some of the |