From patchwork Thu May 30 12:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13680370 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A1F2132121 for ; Thu, 30 May 2024 12:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073498; cv=none; b=lQw95o57cnww673qwhfoqOMEDYaFhzqvzm6+TVJMSxeCfVNgM+EIZBZlbPsq+3MbOYrNdhxmusTj3WHC5VYEq+jleBIU6TwQvt1oaQeujJFoz1M6I0FqdbQZWy+WhsMSGGttj7LR2mygodCsH+950z3SbuEw/Iypg9pT+VxYyI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717073498; c=relaxed/simple; bh=jR+U+drIyHYLyBYosy5SJHyh0/9eaIZ7eOa1ABOYapo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qa/I8z0AEfw5CqNT5a5G+vpz0oFOJQRi6wBBK9UxRU0ULR1anFHVe4UnLZuhk8LWg7dgbeoL/dDbyuxD5mXvNjARaSS88zwHbNOBjvCajsYrtsmaCMOIGX8QEh0FKddxDHemCy3O7k3Yd15PRSpxO/dZkwgMFSrsHppkgt6BYJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=gRcpkQTh; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oVu20DWW; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="gRcpkQTh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oVu20DWW" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 35FBF13800D8; Thu, 30 May 2024 08:51:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 30 May 2024 08:51:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1717073496; x=1717159896; bh=eeAFlJlnxA hrqdVgVPL29pYAjKpL3PpZii2VVD/UUGQ=; b=gRcpkQTheA8SdeV/wvI5oX+s06 APdP8X3rGRARa16ncWUIGb4pOdhEvXcWFmhmwjmDNdtYmYR6M3AH5EmgcM53DQYu I+yZVkmJDp3CEGnpohjG+FekciccT0mPcMIhPa8Z65PoIgTAnZeXAZsmskrmpNFB fne5D+j1Lsc2w9peQZvPdmEZhyMY6HwGZM1APLPo1vpWbtL5RbAWGlxalcV6nrMK gToihWJ4wlXpowNNq170umwzZZ4boltLmoWkKihsFOWkNSh5hv28BlwpDwPXghqJ WPmq04SG3QI7MrXOoeTA5rY+1kXzn1fRVUlFPZcpRvoVK0cwKeeqHtatXfdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1717073496; x=1717159896; bh=eeAFlJlnxAhrqdVgVPL29pYAjKpL 3PpZii2VVD/UUGQ=; b=oVu20DWWlI2ZLohrft5DMKeBcj68EimPEZ410ZM7zSWf rjIkqB+KinHtpufTS1pCw+uHY7mU7tqH7jAiIEoy9GxBYb3Er3xG+H0nGPopISsv lbrOEJqQAuD7cRuhAQNTFZA6kJTQhbEqhygPMB7Rmsa3LJgT72JYjgcIbnFwSJ7N 9FPsYP/cnO8fCQwjicPWQ1HwJxI2zq/3JFtr6EXS4FWwH4kuKmJkDYqw6pA4LVDx L39w8Jzh6FguDFtaf1Kr1tM5HY09fvAjsXNkceQzXNmAime/AtHC6/HFJwwwaVhT GFZa6xFTlZmfmsLWBJjadOK7cOj4abZpwKsD12i6BQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekgedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpeehnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 May 2024 08:51:35 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 0162e285 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 30 May 2024 12:51:19 +0000 (UTC) Date: Thu, 30 May 2024 14:51:33 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v2 13/19] mailmap: always store allocated strings in mailmap blob Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Same as with the preceding commit, the `git_mailmap_blob` may sometimes contain an allocated string and sometimes it may contain a string constant. This is risky and can easily lead to bugs in case the variable is getting re-assigned, where the code may then try to free the previous value to avoid memory leaks. Safeguard the code by always storing allocated strings in the variable. Signed-off-by: Patrick Steinhardt --- mailmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailmap.c b/mailmap.c index b2efe29b3d..3d1e092fef 100644 --- a/mailmap.c +++ b/mailmap.c @@ -216,7 +216,7 @@ int read_mailmap(struct string_list *map) map->cmp = namemap_cmp; if (!git_mailmap_blob && is_bare_repository()) - git_mailmap_blob = "HEAD:.mailmap"; + git_mailmap_blob = xstrdup("HEAD:.mailmap"); if (!startup_info->have_repository || !is_bare_repository()) err |= read_mailmap_file(map, ".mailmap",