From da90c3a9673f3199228b0cab8de52a826a3cfda5 Mon Sep 17 00:00:00 2001 From: mmillerick Date: Tue, 8 Oct 2019 16:11:51 -0700 Subject: [PATCH] fix(connect): Switch new Buffer(size) -> Buffer.alloc(size) --- lib/core/connection/msg.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/connection/msg.js b/lib/core/connection/msg.js index 626da2a860..7bee3c5eeb 100644 --- a/lib/core/connection/msg.js +++ b/lib/core/connection/msg.js @@ -27,6 +27,7 @@ // [uint32 checksum;] // }; +const Buffer = require('safe-buffer').Buffer; const opcodes = require('../wireprotocol/shared').opcodes; const databaseNamespace = require('../wireprotocol/shared').databaseNamespace; const ReadPreference = require('../topologies/read_preference'); @@ -90,7 +91,7 @@ class Msg { flags |= OPTS_EXHAUST_ALLOWED; } - const header = new Buffer( + const header = Buffer.alloc( 4 * 4 + // Header 4 // Flags ); @@ -110,7 +111,7 @@ class Msg { } makeDocumentSegment(buffers, document) { - const payloadTypeBuffer = new Buffer(1); + const payloadTypeBuffer = Buffer.alloc(1); payloadTypeBuffer[0] = 0; const documentBuffer = this.serializeBson(document);