Skip to content

Commit

Permalink
zlib: prevent uncaught exception in zlibBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed May 27, 2015
1 parent 98649fd commit 3b055f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,16 @@ function zlibBuffer(engine, buffer, callback) {
}

function onEnd() {
var buf = Buffer.concat(buffers, nread);
buffers = [];
callback(null, buf);
engine.close();
try {
let buf = Buffer.concat(buffers, nread);
buffers = [];
callback(null, buf);
} catch (e) {
buffers = [];
callback(e);
} finally {
engine.close();
}
}
}

Expand Down

0 comments on commit 3b055f8

Please sign in to comment.