aboutsummaryrefslogtreecommitdiff
path: root/git-p4import.py
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2007-03-20 11:38:34 -0700
committerJunio C Hamano <junkio@cox.net>2007-03-20 22:17:32 -0700
commitac54c277f05c65f441efdc1b9cd7a04aaa6cf75a (patch)
treee47d9b154ee2aab1770b460b8707639ccd59d985 /git-p4import.py
parentacdeec62cb644e48436bbe931e69b3d4842344cb (diff)
downloadgit-ac54c277f05c65f441efdc1b9cd7a04aaa6cf75a.tar.gz
git-ac54c277f05c65f441efdc1b9cd7a04aaa6cf75a.tar.xz
Be more careful about zlib return values
When creating a new object, we use "deflate(stream, Z_FINISH)" in a loop until it no longer returns Z_OK, and then we do "deflateEnd()" to finish up business. That should all work, but the fact is, it's not how you're _supposed_ to use the zlib return values properly: - deflate() should never return Z_OK in the first place, except if we need to increase the output buffer size (which we're not doing, and should never need to do, since we pre-allocated a buffer that is supposed to be able to hold the output in full). So the "while()" loop was incorrect: Z_OK doesn't actually mean "ok, continue", it means "ok, allocate more memory for me and continue"! - if we got an error return, we would consider it to be end-of-stream, but it could be some internal zlib error. In short, we should check for Z_STREAM_END explicitly, since that's the only valid return value anyway for the Z_FINISH case. - we never checked deflateEnd() return codes at all. Now, admittedly, none of these issues should ever happen, unless there is some internal bug in zlib. So this patch should make zero difference, but it seems to be the right thing to do. We should probablybe anal and check the return value of "deflateInit()" too! Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-p4import.py')
0 files changed, 0 insertions, 0 deletions