On 8/4/25 6:56 PM, Toon Claes wrote: > There were two callsites setting the size and address of the output > buffer. Instead of setting them outside the loop and in the loop after > calling git_deflate(). Set them once in the loop, right before the > git_deflate() call. > > Co-authored-by: Justin Tobler <jltobler@xxxxxxxxx> > Signed-off-by: Toon Claes <toon@xxxxxxxxx> > --- > archive-zip.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/archive-zip.c b/archive-zip.c > index df8866d5ba..cc6d0cadd9 100644 > --- a/archive-zip.c > +++ b/archive-zip.c > @@ -458,8 +458,6 @@ static int write_zip_entry(struct archiver_args *args, > git_deflate_init_raw(&zstream, args->compression_level); > > compressed_size = 0; > - zstream.next_out = compressed; > - zstream.avail_out = sizeof(compressed); > > for (;;) { > readlen = read_istream(stream, buf, sizeof(buf)); > @@ -473,6 +471,8 @@ static int write_zip_entry(struct archiver_args *args, > > zstream.next_in = buf; > zstream.avail_in = readlen; > + zstream.next_out = compressed; > + zstream.avail_out = sizeof(compressed); > result = git_deflate(&zstream, 0); > if (result != Z_OK) > die(_("deflate error (%d)"), result); > @@ -481,8 +481,6 @@ static int write_zip_entry(struct archiver_args *args, > if (out_len > 0) { > write_or_die(1, compressed, out_len); > compressed_size += out_len; > - zstream.next_out = compressed; > - zstream.avail_out = sizeof(compressed); > } > > } > Less lines, great! This works because for out_len == 0 these assignments are noops, and that condition so unlikely to be true that we don't need to worry about the then unnecessary writes. René