From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 4/4] xdiff/xmerge: fix chg0 initialization
Date: Sun, 13 Jun 2021 17:58:36 -0500 [thread overview]
Message-ID: <20210613225836.1009569-5-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20210613225836.1009569-1-felipe.contreras@gmail.com>
chg0 is needed when style is XDL_MERGE_DIFF3, xdl_refine_conflicts()
currently is only called when level >= XDL_MERGE_ZEALOUS, which cannot
happen since the level is capped to XDL_MERGE_EAGER.
However, if at some point in the future we decide to not cap diff3, or
introduce a similar uncapped mode, an uninitialized chg0 would cause a
crash.
Let's initialize it to be safe.
Cc: Jeff King <peff@peff.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
xdiff/xmerge.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index b5b3f56f92..d9b3a0dccd 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -333,7 +333,7 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
mmfile_t t1, t2;
xdfenv_t xe;
xdchange_t *xscr, *x;
- int i1 = m->i1, i2 = m->i2;
+ int i0 = m->i0, i1 = m->i1, i2 = m->i2;
/* let's handle just the conflicts */
if (m->mode)
@@ -384,6 +384,8 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
m->next = m2;
m = m2;
m->mode = 0;
+ m->i0 = i0;
+ m->chg0 = 0;
m->i1 = xscr->i1 + i1;
m->chg1 = xscr->chg1;
m->i2 = xscr->i2 + i2;
--
2.32.0
next prev parent reply other threads:[~2021-06-13 22:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-13 22:58 [PATCH 0/4] merge: cleanups and fix Felipe Contreras
2021-06-13 22:58 ` [PATCH 1/4] merge: simplify initialization Felipe Contreras
2021-06-15 19:27 ` Ævar Arnfjörð Bjarmason
2021-06-17 22:35 ` Felipe Contreras
2021-06-13 22:58 ` [PATCH 2/4] merge: fix Yoda conditions Felipe Contreras
2021-06-13 22:58 ` [PATCH 3/4] xdiff/xmerge: simplify xdl_recs_copy_0 Felipe Contreras
2021-06-13 22:58 ` Felipe Contreras [this message]
2021-06-14 15:34 ` [PATCH 4/4] xdiff/xmerge: fix chg0 initialization Elijah Newren
2021-06-15 7:51 ` Felipe Contreras
2021-06-15 15:21 ` Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210613225836.1009569-5-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).