Subject: Re: Error in `git': free(): invalid pointer (was Re: [PATCH] sequencer: improve config handling)

From: "[email-masked]" <[email-masked]>
Date: Thu, 21 Dec 2017 16:53:49 +0000 (GMT)

>----Original Message----
>From: [email-masked]
>Date: 20/12/2017 18:33 
>To: "Phillip Wood"<[email-masked]>, "Git Mailing List"
<[email-masked]>
>Cc: "Johannes Schindelin"<[email-masked]>
>Subj: Error in `git&#39;: free(): invalid pointer (was Re: [PATCH] 
sequencer: improve config handling)
>
>I recently encountered that error when trying to do an interactive
>rebase after using filter-branch to remove a file completely in a
>repository. I bisected this issue which pointed at this patch. I'm not
>sure how it is related as I'm not too familiar with the sequencer 
code.
>I could help in case any specific information is needed. As a first
>step, I've posted the output of "strace /mnt/Source//Git/git rebase -i
>HEAD~10" below.
>

Hm, There is a problem with sequencer_remove_state() which does 

free(opts->gpg_sign)

however unless a gpg key was given on the commandline, opts->gpg is 
initialized to "" which is statically allocated. 

This untested diff should fix that, but I'm not sure if you're problem 
is related to it (I'm visiting relatives so don't have much time for 
working at the moment. also I'm on webmail so apologies if the patch is 
mangled)

Best Wishes

Phillip
>-- 8< --

diff --git a/sequencer.c b/sequencer.c
index 3bc487573..115ceba91 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -160,7 +160,7 @@ static int git_sequencer_config(const char *k, 
const char *v, void *cb)
        }
 
        if (!strcmp(k, "commit.gpgsign")) {
-               opts->gpg_sign = git_config_bool(k, v) ? "" : NULL;
+               opts->gpg_sign = git_config_bool(k, v) ? strdup("") : 
NULL;
                return 0;
        }