emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-30 ed38fcc0170 1/2: Fix segfault when deleting tree-sitter query (


From: Yuan Fu
Subject: emacs-30 ed38fcc0170 1/2: Fix segfault when deleting tree-sitter query (bug#72238)
Date: Sun, 21 Jul 2024 20:28:45 -0400 (EDT)

branch: emacs-30
commit ed38fcc01703d166d8a63989f8167b50ebd954a0
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    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.
---
 src/treesit.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/treesit.c b/src/treesit.c
index 3ae55d77a91..416c1edf791 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.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]