diff --git a/lib/tools/isbinaryfile.js b/lib/tools/isbinaryfile.js index 65f37fdf6..7b0135d08 100644 --- a/lib/tools/isbinaryfile.js +++ b/lib/tools/isbinaryfile.js @@ -18,7 +18,7 @@ module.exports = function(bytes, size) { } var descriptor = fs.openSync(file, 'r'); try { - bytes = new Buffer(max_bytes); + bytes = Buffer.alloc(max_bytes); size = fs.readSync(descriptor, bytes, 0, bytes.length, 0); } finally { fs.closeSync(descriptor); @@ -32,7 +32,7 @@ module.exports = function(bytes, size) { fs.open(file, 'r', function(err, descriptor){ if (err) return callback(err); - var bytes = new Buffer(max_bytes); + var bytes = Buffer.alloc(max_bytes); // Read the file with no encoding for raw buffer access. fs.read(descriptor, bytes, 0, bytes.length, 0, function(err, size, bytes){ fs.close(descriptor, function(err2){