From: Yuan Fu Date: Sun, 21 Jul 2024 23:50:59 +0000 (-0700) Subject: Fix segfault when deleting tree-sitter query (bug#72238) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=953e6b37c3c410e234beef485599d532d1496d8d;p=emacs.git Fix segfault when deleting tree-sitter query (bug#72238) * src/treesit.c (treesit_delete_query): Only delete query and cursor when they are non-NULL. (cherry picked from commit 4868a17396b6796b77285a3608b383aac32aee4f) --- diff --git a/src/treesit.c b/src/treesit.c index 5ed15bca788..a420ef77b2d 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -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. */