From patchwork Mon Aug 26 02:43:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Wong X-Patchwork-Id: 11113833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1D0D1800 for ; Mon, 26 Aug 2019 02:43:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 898A12173E for ; Mon, 26 Aug 2019 02:43:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729141AbfHZCng (ORCPT ); Sun, 25 Aug 2019 22:43:36 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:36260 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbfHZCnf (ORCPT ); Sun, 25 Aug 2019 22:43:35 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 91D911F4B7; Mon, 26 Aug 2019 02:43:32 +0000 (UTC) From: Eric Wong To: Junio C Hamano Cc: git@vger.kernel.org Subject: [PATCH 01/11] diff: use hashmap_entry_init on moved_entry.ent Date: Mon, 26 Aug 2019 02:43:22 +0000 Message-Id: <20190826024332.3403-2-e@80x24.org> In-Reply-To: <20190826024332.3403-1-e@80x24.org> References: <20190826024332.3403-1-e@80x24.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Otherwise, the hashmap_entry.next field appears to remain uninitialized, which can lead to problems when add_lines_to_move_detection calls hashmap_add. I found this through manual inspection when converting hashmap_add callers to take "struct hashmap_entry *". Signed-off-by: Eric Wong --- diff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diff.c b/diff.c index efe42b341a..02491ee684 100644 --- a/diff.c +++ b/diff.c @@ -964,8 +964,9 @@ static struct moved_entry *prepare_entry(struct diff_options *o, struct moved_entry *ret = xmalloc(sizeof(*ret)); struct emitted_diff_symbol *l = &o->emitted_symbols->buf[line_no]; unsigned flags = o->color_moved_ws_handling & XDF_WHITESPACE_FLAGS; + unsigned int hash = xdiff_hash_string(l->line, l->len, flags); - ret->ent.hash = xdiff_hash_string(l->line, l->len, flags); + hashmap_entry_init(&ret->ent, hash); ret->es = l; ret->next_line = NULL;