Skip to content

Commit

Permalink
Handle concatenated gzip files. Fixes nodejs#6032.
Browse files Browse the repository at this point in the history
  • Loading branch information
eendeego committed Oct 31, 2013
1 parent c993cfb commit fd080ed
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ class ZCtx : public WeakObject {
in = nada;
in_len = 0;
in_off = 0;
} else if (ctx->err_ == Z_STREAM_END) {
in = ctx->strm_.next_in;
in_len = ctx->strm_.avail_in;
out = ctx->strm_.next_out;
out_len = ctx->strm_.avail_out;
} else {
assert(Buffer::HasInstance(args[1]));
Local<Object> in_buf;
Expand Down Expand Up @@ -239,6 +244,17 @@ class ZCtx : public WeakObject {
// input.
ctx->err_ = Z_NEED_DICT;
}
} else if (ctx->err_ == Z_STREAM_END) {
// Id there's more data available
if (ctx->strm_.avail_in > 0) {
// Reset the stream
ctx->err_ = inflateReset(&ctx->strm_);

if (ctx->err_ == Z_OK) {
// And read it
ctx->err_ = inflate(&ctx->strm_, ctx->flush_);
}
}
}
break;
default:
Expand Down

0 comments on commit fd080ed

Please sign in to comment.