Skip to content

Commit

Permalink
Merge pull request #239 from keyesdav/bug-234-fix
Browse files Browse the repository at this point in the history
Fix Buffer.alloc bug #234
  • Loading branch information
cthackers committed Oct 11, 2018
2 parents 83d44ba + 6306ee9 commit c309c92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zipFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ module.exports = function (/*String|Buffer*/input, /*Number*/inputType) {
entry.header.offset = dindex;
// data header
var dataHeader = entry.header.dataHeaderToBinary();
var postHeader = Buffer.from(name);
var postHeader;
try {
postHeader = Buffer.alloc(name.length, name); // using alloc will work on node 5.x+
} catch(e){
postHeader = new Buffer(name); // use deprecated method if alloc fails...
}
var dataLength = dataHeader.length + postHeader.length + compressedData.length;

dindex += dataLength;
Expand Down

0 comments on commit c309c92

Please sign in to comment.