]> git.ipfire.org Git - thirdparty/git.git/commit
diff-lib: add idx/tree sanity check to oneway_diff
authorJeff King <peff@peff.net>
Tue, 28 Jul 2026 15:14:58 +0000 (11:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jul 2026 16:12:24 +0000 (09:12 -0700)
commit447126ed7df66b396235766547a57649f925aac2
treef130ecd06bdfb3fd8734defd697f91cc9df9f594
parent88efab5c3b7b7585a3b4f45db89c108fef9a04f2
diff-lib: add idx/tree sanity check to oneway_diff

When looking just at the code in oneway_diff(), it seems possible for
both "idx" and "tree" to be NULL, in which case we'd potentially
segfault while checking the relative prefix.

But if you consider what these items actually mean, it shouldn't be
possible for both to be NULL. Let's add an assertion and a comment
documenting this. It might help human readers, but should also silence
static analyzers like Coverity which complain about the potential
segfault.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c