emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs-29 c9ba05af8d: Fix crashes inside 'xfree' called from treesit.


From: Eli Zaretskii
Subject: Re: emacs-29 c9ba05af8d: Fix crashes inside 'xfree' called from treesit.c
Date: Wed, 08 Feb 2023 18:42:15 +0200

> From: Eric Gillespie <epg@pretzelnet.org>
> Date: Wed, 08 Feb 2023 09:43:51 -0600
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > commit c9ba05af8dfabca00023bd2312dec4ec59497801
> > diff --git a/src/treesit.c b/src/treesit.c
> > index 8e772523cc..b15d44fca0 100644
> > --- a/src/treesit.c
> > +++ b/src/treesit.c
> > @@ -620,7 +620,7 @@ treesit_load_language (Lisp_Object language_symbol,
> >    char *c_name = xstrdup (SSDATA (base_name));
> >    treesit_symbol_to_c_name (c_name);
> >    if (found_override)
> > -    c_name = SSDATA (override_c_name);
> > +    c_name = xstrdup (SSDATA (override_c_name));
> >    langfn = dynlib_sym (handle, c_name);
> >    xfree (c_name);
> >    error = dynlib_error ();
> 
> Isn't the memory allocated on line 620 (in the initial c_name
> assignment) leaked when found_override is true?
> 
> It looks like this dates to commit
> 1cd42bfb8a5ff2aade43f31b864a8d2cd643d5a3, which, ironically, was
> fixing another memory leak.  It looks like this code has been
> suffering a lot of memory issues, actually.
> 
> Maybe I'm misunderstanding, but it looks to me like not only is
> the memory initially pointed to by c_name leaked, but that that
> allocation is unnecessary when found_override is true, along with
> the work done by treesit_symbol_to_c_name.
> 
> Is this wrong?

Thanks, you are right.  I fixed this (hopefully) using almost the same
code as you suggested.



reply via email to

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