Re: git 1.5.1-rc1 doesn't like empty files
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Mar 20, 2007, 05:49 UTC
- Message-ID
- <Pine.LNX.4.64.0703192245490.6730@woody.linux-foundation.org>
- In-Reply-To
- <7vslc0bhz7.fsf@assigned-by-dhcp.cox.net>
On Mon, 19 Mar 2007, Junio C Hamano wrote:
> > If the error message above is linewrapped by e-mail, I think it > is coming from here:
I think I found it.
The thing is, if the output buffer is empty, we should *still* actually use the zlib routines to *unpack* that empty output buffer.
But we had a test that said "only unpack if we still expect more output".
So we wouldn't use up all the zlib stream, because we felt that we didn't need it, because we already had all the bytes we wanted. And it was "true": we did have all the output data. We just needed to also eat all the input data!
We've had this bug before - thinking that we don't need to inflate() anything because we already had it all..
Linus
--- sha1_file.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c index b0b2177..c0efed3 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1030,7 +1030,7 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size n = size; memcpy(buf, (char *) buffer + bytes, n); bytes = n; - if (bytes < size) { + if (bytes <= size) { stream->next_out = buf + bytes; stream->avail_out = size - bytes; while (status == Z_OK)