[erlang-patches] Patch to add zlib:crc32_combine/4 and zlib:adler32_combine/4
Matthew Dempsky
matthew@REDACTED
Wed Nov 14 01:46:35 CET 2007
Some further testing with the zipchunk module revealed that the
zlib_drv does not properly flush the zlib buffers. In particular, a
call to zlib:deflate(Z, Binary, full) can leave part of Binary still
in Z's internal state.
The patch below properly follows the advice of zlib.h that ``If
deflate returns with avail_out == 0, this function must be called
again with the same value of the flush parameter and more output space
(updated avail_out).''
Also, Z_STREAM_END is only returned when Z_FINISH is given.
--- otp_src_R11B-5/erts/emulator/drivers/common/zlib_drv.c.orig 2007-11-06
11:44:12.000000000 -0800
+++ otp_src_R11B-5/erts/emulator/drivers/common/zlib_drv.c 2007-11-13
16:39:48.000000000 -0800
@@ -323,12 +323,15 @@
}
}
} else {
- while (d->s.avail_out < d->binsz) {
+ while (d->s.avail_out == 0) {
zlib_output(d);
- if (res == Z_STREAM_END) {
- break;
+ if ((res = deflate(&d->s, flush)) < 0) {
+ return res;
}
}
+ if (d->s.avail_out < d->binsz) {
+ zlib_output(d);
+ }
}
}
return res;
More information about the erlang-patches
mailing list