aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2023-08-12 15:06:48 +0300
committerEli Zaretskii2023-08-12 15:06:48 +0300
commit8dbd5aa1eef9db956ad3a4ed73add23fe0e48268 (patch)
treeb2e98187dec6501fea6b2504f0d3509132515254 /src
parent47b4f4cf7839cda8e12ad5f808444cd0cf8f8824 (diff)
downloademacs-8dbd5aa1eef9db956ad3a4ed73add23fe0e48268.tar.gz
emacs-8dbd5aa1eef9db956ad3a4ed73add23fe0e48268.zip
Avoid crashes in 'display_count_lines' when current buffer was killed
* src/xdisp.c (Fformat_mode_line): * src/fns.c (Fline_number_at_pos): Don't allow to count lines in a dead buffer. (Bug#65060)
Diffstat (limited to 'src')
-rw-r--r--src/fns.c3
-rw-r--r--src/xdisp.c2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/fns.c b/src/fns.c
index 2ed62d6e8c6..af5f9479a36 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -6123,6 +6123,9 @@ from the absolute start of the buffer, disregarding the narrowing. */)
6123{ 6123{
6124 ptrdiff_t pos_byte, start_byte = BEGV_BYTE; 6124 ptrdiff_t pos_byte, start_byte = BEGV_BYTE;
6125 6125
6126 if (!BUFFER_LIVE_P (current_buffer))
6127 error ("Attempt to count lines in a dead buffer");
6128
6126 if (MARKERP (position)) 6129 if (MARKERP (position))
6127 { 6130 {
6128 /* We don't trust the byte position if the marker's buffer is 6131 /* We don't trust the byte position if the marker's buffer is
diff --git a/src/xdisp.c b/src/xdisp.c
index 22508978298..11417070804 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -27653,6 +27653,8 @@ are the selected window and the WINDOW's buffer). */)
27653 if (NILP (buffer)) 27653 if (NILP (buffer))
27654 buffer = w->contents; 27654 buffer = w->contents;
27655 CHECK_BUFFER (buffer); 27655 CHECK_BUFFER (buffer);
27656 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
27657 error ("Attempt to format a mode line for a dead buffer");
27656 27658
27657 /* Make formatting the modeline a non-op when noninteractive, otherwise 27659 /* Make formatting the modeline a non-op when noninteractive, otherwise
27658 there will be problems later caused by a partially initialized frame. */ 27660 there will be problems later caused by a partially initialized frame. */