Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-21 Thread Jeff King
On Thu, Jun 21, 2018 at 09:03:05AM +0200, Johannes Schindelin wrote: > > > And at that point, maybe > > > > > > char *some_var = xstrdup("default"); > > > git_config_string(_var, ...); > > > > > > that takes "char **" and frees the current storage before assigning to > > > it may be simpler

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-21 Thread Johannes Schindelin
Hi Peff, On Mon, 4 Jun 2018, Jeff King wrote: > On Mon, Jun 04, 2018 at 01:26:57PM +0900, Junio C Hamano wrote: > > > And at that point, maybe > > > > char *some_var = xstrdup("default"); > > git_config_string(_var, ...); > > > > that takes "char **" and frees the current storage

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Jeff King
On Sun, Jun 03, 2018 at 11:56:37PM -0400, Jeff King wrote: > So sometimes some_var needs to be freed and sometimes not (and every one > of those uses is a potential leak, but it's OK because they're all > program-lifetime globals anyway, and people don't _tend_ to set the same > option over and

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Junio C Hamano
Jeff King writes: > With that strategy, we'd have to have a big initialize_defaults() > function. Which actually might not be _too_ bad since we now have > common-main.c, but: > > - it sucks to keep the default values far away from the declarations > > - it does carry a runtime cost. Not a

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Jeff King
On Mon, Jun 04, 2018 at 01:26:57PM +0900, Junio C Hamano wrote: > > Doing it "right" in C would probably involve two variables: > > > > const char *some_var = "default"; > > const char *some_var_storage = NULL; > > > > int git_config_string_smart(const char **ptr, char **storage, > >

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Junio C Hamano
Jeff King writes: > I've looked into it before, but that causes its own wave of headaches. > The source of the problem is that we do: > > const char *some_var = "default"; > ... > git_config_string(_var, ...); Yup, that is a valid pattern for "run once and let exit(3) clean after us"

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Jeff King
On Mon, Jun 04, 2018 at 12:44:15PM +0900, Junio C Hamano wrote: > >> diff --git a/sequencer.c b/sequencer.c > >> index b98690ecd41..aba03e9429a 100644 > >> --- a/sequencer.c > >> +++ b/sequencer.c > >> @@ -175,6 +175,7 @@ static int git_sequencer_config(const char *k, const > >> char *v, void

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Junio C Hamano
Junio C Hamano writes: > Stefan Beller writes: > >> Signed-off-by: Stefan Beller >> --- >> sequencer.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/sequencer.c b/sequencer.c >> index b98690ecd41..aba03e9429a 100644 >> --- a/sequencer.c >> +++ b/sequencer.c >> @@ -175,6 +175,7

Re: [PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-03 Thread Junio C Hamano
Stefan Beller writes: > Signed-off-by: Stefan Beller > --- > sequencer.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/sequencer.c b/sequencer.c > index b98690ecd41..aba03e9429a 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -175,6 +175,7 @@ static int

[PATCH 2/2] sequencer.c: plug mem leak in git_sequencer_config

2018-06-01 Thread Stefan Beller
Signed-off-by: Stefan Beller --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index b98690ecd41..aba03e9429a 100644 --- a/sequencer.c +++ b/sequencer.c @@ -175,6 +175,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)