Re: [PATCH 08/22] config: fix leaking comment character config
- From
James Liu <james@jamesliu.io>
- Date
- Aug 7, 2024, 07:11 UTC
- Message-ID
- <D39HQCFQ2DCW.1KFGPLVU1EVQD@jamesliu.io>
- In-Reply-To
- <a34c90a5527cb45ec89a0ad44dbca1d61705a0ea.1722933642.git.ps@pks.im>
On Tue Aug 6, 2024 at 7:00 PM AEST, Patrick Steinhardt wrote:
Show 18 quoted lines
> Refactor the code so that we initialize the value with another array. > This allows us to free the value in case the string is not pointing to > that constant array anymore. > > diff --git a/environment.c b/environment.c > index 5cea2c9f54..8297c6e37b 100644 > --- a/environment.c > +++ b/environment.c > @@ -113,7 +113,8 @@ int protect_ntfs = PROTECT_NTFS_DEFAULT; > * The character that begins a commented line in user-editable file > * that is subject to stripspace. > */ > -const char *comment_line_str = "#"; > +const char comment_line_str_default[] = "#"; > +const char *comment_line_str = comment_line_str_default; > int auto_comment_line_char; > > /* Parallel index stat data preload? */
Is my understanding correct that `comment_line_str` is now just a pointer to the `comment_line_str_default` array, and thus can be freed once we're done with it?