]> git.ipfire.org Git - thirdparty/git.git/commit
diffstat_consume(): assert non-zero length
authorJeff King <peff@peff.net>
Tue, 18 Oct 2022 01:01:17 +0000 (21:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Oct 2022 04:24:03 +0000 (21:24 -0700)
commit0e5a87e0422ff308641199d1afe94b58e1249bc0
tree16018406025a5754a5525fb713726040c851d051
parent3dcec76d9df911ed8321007b1d197c1a206dc164
diffstat_consume(): assert non-zero length

The callback interface for xdiff_emit_line_fn gives us a line/len pair,
but diffstat_consume() never looks at "len". At first glance this seems
like a bug that could cause us to read further than xdiff intends. But
in practice, we read only the first character, and xdiff would never
pass us an empty line.

Let's add a run-time assertion that this is true, which clarifies our
assumption and silences -Wunused-parameter.

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