Skip to content

Commit c657aa0

Browse files
committed
Merge branch 'jk/stream-pack-non-delta-clarification'
Additional comment on a tricky piece of code to help developers. * jk/stream-pack-non-delta-clarification: read_istream_pack_non_delta(): document input handling
2 parents 81c365b + 0afbe3e commit c657aa0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

streaming.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,15 @@ static read_method_decl(pack_non_delta)
408408
st->z_state = z_done;
409409
break;
410410
}
411+
412+
/*
413+
* Unlike the loose object case, we do not have to worry here
414+
* about running out of input bytes and spinning infinitely. If
415+
* we get Z_BUF_ERROR due to too few input bytes, then we'll
416+
* replenish them in the next use_pack() call when we loop. If
417+
* we truly hit the end of the pack (i.e., because it's corrupt
418+
* or truncated), then use_pack() catches that and will die().
419+
*/
411420
if (status != Z_OK && status != Z_BUF_ERROR) {
412421
git_inflate_end(&st->z);
413422
st->z_state = z_error;

0 commit comments

Comments
 (0)