]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix segfault when deleting tree-sitter query (bug#72238)
authorYuan Fu <casouri@gmail.com>
Sun, 21 Jul 2024 23:50:59 +0000 (16:50 -0700)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Jul 2024 10:39:14 +0000 (12:39 +0200)
* src/treesit.c (treesit_delete_query): Only delete query and cursor
when they are non-NULL.

(cherry picked from commit 4868a17396b6796b77285a3608b383aac32aee4f)

src/treesit.c

index 5ed15bca78804f19ca119ec8522f6191e5f0fb94..a420ef77b2d3fec61e56277aa28b4571a92298cc 100644 (file)
@@ -1224,8 +1224,10 @@ treesit_delete_parser (struct Lisp_TS_Parser *lisp_parser)
 void
 treesit_delete_query (struct Lisp_TS_Query *lisp_query)
 {
-  ts_query_delete (lisp_query->query);
-  ts_query_cursor_delete (lisp_query->cursor);
+  if (lisp_query->query)
+    ts_query_delete (lisp_query->query);
+  if (lisp_query->cursor)
+    ts_query_cursor_delete (lisp_query->cursor);
 }
 
 /* The following function is called from print.c:print_vectorlike.  */