summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2024-06-01 10:20:48 -0700
committerYuan Fu <casouri@gmail.com>2024-06-01 10:29:55 -0700
commit20af58d3a13ddb5c2ca376da8cdd3fde4833ca2d (patch)
tree34911232c2aa99244baef21db031ee6a8b326e30 /src/print.c
parentbf50aa38f9d2a3a5af8d32ce139c7533c912c476 (diff)
downloademacs-20af58d3a13ddb5c2ca376da8cdd3fde4833ca2d.tar.gz
emacs-20af58d3a13ddb5c2ca376da8cdd3fde4833ca2d.tar.bz2
emacs-20af58d3a13ddb5c2ca376da8cdd3fde4833ca2d.zip
Check for buffer liveness when accessing tree-sitter node (bug#71012)
* src/treesit.h (treesit_node_buffer_live_p): Declare function. * src/print.c (print_vectorlike): Print node without position if buffer is killed. * src/treesit.c (treesit_node_buffer_live_p): New function. (treesit_check_node): Add buffer liveness check. (syms_of_treesit): New error treesit-node-buffer-killed.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/print.c b/src/print.c
index d52d98ad371..8ee5a3616eb 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2029,6 +2029,11 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
print_c_string ("-outdated>", printcharfun);
break;
}
+ if (!treesit_node_buffer_live_p (obj))
+ {
+ print_c_string ("-in-killed-buffer>", printcharfun);
+ break;
+ }
printchar (' ', printcharfun);
/* Now the node must be up-to-date, and calling functions like
Ftreesit_node_start will not signal. */