]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix memory leak in treesit.c
authorEli Zaretskii <eliz@gnu.org>
Wed, 8 Feb 2023 16:40:50 +0000 (18:40 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 8 Feb 2023 16:40:50 +0000 (18:40 +0200)
* src/treesit.c (treesit_load_language): Fix a memory leak.
Reported by Eric Gillespie <epg@pretzelnet.org>.

src/treesit.c

index b15d44fca0190a7dc449c3aa312e9b51a3c1e639..cfa3721b5e7521ba0ca9f2181c02da206ab64c56 100644 (file)
@@ -617,10 +617,14 @@ treesit_load_language (Lisp_Object language_symbol,
   eassume (handle != NULL);
   dynlib_error ();
   TSLanguage *(*langfn) (void);
-  char *c_name = xstrdup (SSDATA (base_name));
-  treesit_symbol_to_c_name (c_name);
+  char *c_name;
   if (found_override)
     c_name = xstrdup (SSDATA (override_c_name));
+  else
+    {
+      c_name = xstrdup (SSDATA (base_name));
+      treesit_symbol_to_c_name (c_name);
+    }
   langfn = dynlib_sym (handle, c_name);
   xfree (c_name);
   error = dynlib_error ();