From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6040F1F461 for ; Tue, 20 Aug 2019 16:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730088AbfHTQhj (ORCPT ); Tue, 20 Aug 2019 12:37:39 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:58751 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728682AbfHTQhj (ORCPT ); Tue, 20 Aug 2019 12:37:39 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 9172C173559; Tue, 20 Aug 2019 12:37:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=TNIkbBf0H+syX5/Ra2TSivM9UJM=; b=Lo+L6S Or0y1KE/cPdF78t3c80jtG1HSM+SeRyUoiKrgvly5RcPMr7DctlhPVT2wYk/Gavm UxhWU04CpxjHMf4lo/Ic+bez0cS7EUrrOXYmi/PVmewwSdseqRx3TVqolVUBCCSW 6wynROzqmompARs7wimqL5LvjX5yWS/jF61D0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=F0qYoU5vwZDBUfm/o8UoA+fa3ZSGk+ZK 9NnqA211KTaig/lEBvH5mVFi31ai0MvzUGBHj4a3FmuRqoLfDtZvuQ4qLpD8AA+5 zmOVDzPMUtzyfCOXwl4PMseAjvjWbzZuwsAS8Uw9twswwpudshxiq4w/YGb1+yxR hKvc5xQfUC4= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 86FA8173557; Tue, 20 Aug 2019 12:37:36 -0400 (EDT) Received: from pobox.com (unknown [34.76.80.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id E7CE7173553; Tue, 20 Aug 2019 12:37:35 -0400 (EDT) From: Junio C Hamano To: Mischa POSLAWSKY Cc: git@vger.kernel.org, =?utf-8?B?0J7Qu9GPINCi0LXQu9C10LbQvdCw0Y8=?= Subject: Re: [PATCH] ref-filter: initialize empty name or email fields References: <20190817215107.13733-1-git@shiar.nl> Date: Tue, 20 Aug 2019 09:37:34 -0700 In-Reply-To: (Junio C. Hamano's message of "Mon, 19 Aug 2019 10:55:13 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: D0DCF590-C368-11E9-AE60-46F8B7964D18-77302942!pb-smtp1.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Junio C Hamano writes: > Mischa POSLAWSKY writes: > >> Formatting $(taggername) on headerless tags such as v0.99 in Git >> causes a SIGABRT with error "munmap_chunk(): invalid pointer", >> because of an oversight in commit f0062d3b74 (ref-filter: free >> item->value and item->value->s, 2018-10-19). >> >> Signed-off-by: Mischa POSLAWSKY >> --- >> If I understand correctly, such tags cannot be produced normally anymore. >> Therefore I'm unsure how to make tests, and if that is even warranted. > > Thanks for spotting. > > I am not sure if the approach taken by this patch is the right one, > though. I didn't follow the call/dataflow thoroughly, but if we > replace unfree-able "" with NULL in these places, wouldn't > fill_missing_values() take care of them? I think replacing these "" with NULL would be safe, but there are many places that return xstrdup("") from inside the callees of populate_value(), so the patch presented here would be more consistent with the current practice, I think. So let's take the patch as is, at least for now. Thanks. >> ref-filter.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/ref-filter.c b/ref-filter.c >> index f27cfc8c3e..7338cfc671 100644 >> --- a/ref-filter.c >> +++ b/ref-filter.c >> @@ -1028,7 +1028,7 @@ static const char *copy_name(const char *buf) >> if (!strncmp(cp, " <", 2)) >> return xmemdupz(buf, cp - buf); >> } >> - return ""; >> + return xstrdup(""); >> } >> >> static const char *copy_email(const char *buf) >> @@ -1036,10 +1036,10 @@ static const char *copy_email(const char *buf) >> const char *email = strchr(buf, '<'); >> const char *eoemail; >> if (!email) >> - return ""; >> + return xstrdup(""); >> eoemail = strchr(email, '>'); >> if (!eoemail) >> - return ""; >> + return xstrdup(""); >> return xmemdupz(email, eoemail + 1 - email); >> }