>>>> "sjt" == Stephen J Turnbull
<stephen(a)xemacs.org> writes:
sjt> Bingo! And down we go. That should give us something to
sjt> work with.
sjt> My time comes in bits and pieces,
It only took a bit. ;-) Try the patch below. As the comment says, I
want to review other uses of the syntax cache for similar bugs. I
also need to check if 21.4 is vulnerable.
diff --git a/src/syntax.c b/src/syntax.c
index be92bb1..e48b7e4 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -389,14 +389,20 @@ signal_syntax_table_extent_changed (EXTE
if (BUFFERP (buffer))
{
struct syntax_cache *cache = XBUFFER (buffer)->syntax_cache;
- Bytexpos start = extent_endpoint_byte (extent, 0);
- Bytexpos end = extent_endpoint_byte (extent, 1);
- Bytexpos start2 = byte_marker_position (cache->start);
- Bytexpos end2 = byte_marker_position (cache->end);
- /* If the extent is entirely before or entirely after the cache range,
- it doesn't overlap. Otherwise, invalidate the range. */
- if (!(end < start2 || start > end2))
- reset_buffer_cache_range (cache, buffer);
+ /* #### REVIEW FOR OTHER PLACES THIS BUG CAN STRIKE */
+ /* This can get called before the buffer's cache gets used, eg in
+ cperl mode. Cf on xemacs-beta. */
+ if (!NILP (cache->start))
+ {
+ Bytexpos start = extent_endpoint_byte (extent, 0);
+ Bytexpos end = extent_endpoint_byte (extent, 1);
+ Bytexpos start2 = byte_marker_position (cache->start);
+ Bytexpos end2 = byte_marker_position (cache->end);
+ /* If the extent is entirely before or entirely after the cache
+ range, it doesn't overlap. Otherwise, invalidate the range. */
+ if (!(end < start2 || start > end2))
+ reset_buffer_cache_range (cache, buffer);
+ }
}
}
--
School of Systems and Information Engineering
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.