Skip to content

Z_BUF_ERROR is not valid for BZip2_Compress #8

Closed

Description

@mdcallag

This code doesn't compile when bzip2 is installed but zlib is not. Regardless is it not correct to use Z_BUF_ERROR here.

see http://www.bzip.org/1.0.3/html/low-level.html

int old_sz =0, new_sz =0;
while(_stream.next_in != nullptr && _stream.avail_in != 0) {
int st = BZ2_bzCompress(&_stream, BZ_FINISH);
switch (st) {
case BZ_STREAM_END:
break;
case BZ_FINISH_OK:
// No output space. Increase the output space by 20%.
// (Should we fail the compression since it expands the size?)
old_sz = output->size();
new_sz = (int)(output->size() * 1.2);
output->resize(new_sz);
// Set more output.
_stream.next_out = (char _)&(_output)[old_sz];
_stream.avail_out = new_sz - old_sz;
break;
case Z_BUF_ERROR:
default:
BZ2_bzCompressEnd(&_stream);
return false;
}
}

Activity

  1. mdcallag commented on Nov 17, 2013

    @mdcallag
    ContributorAuthor

    And BZip2_Uncompress uses Z_OK and Z_BUF_ERROR which also come from zlib. Those references should be changed to BZ_* equivalents.

  2. added a commit that references this issue on Nov 19, 2013
  3. igorcanadi commented on Nov 19, 2013

    @igorcanadi
    Contributor

    Tnx Mark, I fixed the problem.

  4. added a commit that references this issue on Apr 25, 2014
  5. added a commit that references this issue on Dec 2, 2017
  6. added a commit that references this issue on Jul 14, 2018
  7. 70 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions