From 0d7676a871d32b251b0e809c33b0abffc882cec6 Mon Sep 17 00:00:00 2001 From: David Stephens Date: Sat, 28 Apr 2018 14:06:36 +0100 Subject: [PATCH] Buffer.alloc to init Buffer with a length --- core/archive_util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/archive_util.js b/core/archive_util.js index 8ce2abc2..346e569e 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -82,7 +82,7 @@ module.exports = class ArchiveUtil { fileType.offset = fileType.offset || 0; // :TODO: this is broken: sig is NOT this long, it's sig.length long; offset needs to allow for -negative values as well - const sigLen =fileType.offset + fileType.sig.length; + const sigLen = fileType.offset + fileType.sig.length; if(sigLen > this.longestSignature) { this.longestSignature = sigLen; } @@ -120,7 +120,7 @@ module.exports = class ArchiveUtil { return cb(err); } - const buf = Buffer.from(this.longestSignature); + const buf = Buffer.alloc(this.longestSignature); fs.read(fd, buf, 0, buf.length, 0, (err, bytesRead) => { if(err) { return cb(err);