From d11d7aee1a6f4d675214353204a6f5655c1caa4b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 8 Feb 2023 18:40:50 +0200 Subject: [PATCH] ; Fix memory leak in treesit.c * src/treesit.c (treesit_load_language): Fix a memory leak. Reported by Eric Gillespie . --- src/treesit.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/treesit.c b/src/treesit.c index b15d44fca01..cfa3721b5e7 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -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 (); -- 2.39.2