Thread (1 message) 1 message, 1 author, 2021-02-09

Re: [PATCH v3 3/3] ref-filter: use pretty.c logic for trailers

From: brian m. carlson <hidden>
Date: 2021-02-09 03:08:29
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

On 2021-02-08 at 19:54:18, Junio C Hamano wrote:
Junio C Hamano [off-list ref] writes:
quoted
By the way, when merged to 'seen' (you can try the above that shows
%(subject) followed by %(trailers) with the tip of 'seen'), it dies
like this:

    $ git for-each-ref \
	--format="%(subject)%0a%(trailers:key=Signed-off-by:)" \
	refs/heads/js/range-diff-wo-dotdot
    free(): double free detected in tcache 2
    Aborted

There must be some interaction with another topic but I didn't dig
deeper.
It seems brian's bc/signed-objects-with-both-hashes topic alone has
the double-free issue, without the "trailers" topic.

    $ git checkout --detach bc/signed-objects-with-both-hashes
    $ make git
    $ ./git for-each-ref --format='%(subject)%(body)' refs/heads/maint
    free(): double free detected in tcache 2
    Aborted

So for now, you do not have to worry about it in your topic.  Of
course, you are very much welcome to help debugging and fixing it
;-)
I'll send out a fixed patch tomorrow, but for the moment, here's the
gist of the change if you want to an immediate fix to squash in:

------- %< ---------
diff --git a/ref-filter.c b/ref-filter.c
index e6c8106377..5f8a443be5 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1344,8 +1344,8 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)
 		} else if (atom->u.contents.option == C_BARE)
 			v->s = xstrdup(subpos);
 
-		free((void *)sigpos);
 	}
+	free((void *)sigpos);
 }
 
 /*
------- %< ---------
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help