From 8b1bbe3a599bb2560fc2dc74961d4e2156395f41 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 14 Aug 2017 12:54:05 +0200 Subject: [PATCH] buffer: fix MAX_LENGTH constant export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was a typo and accidentally returned the wrong value. Fixes: https://github.com/nodejs/node/issues/14819 Ref: https://github.com/nodejs/node/pull/13467 PR-URL: https://github.com/nodejs/node/pull/14821 Reviewed-By: Evan Lucas Reviewed-By: Yuta Hiroto Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso --- lib/buffer.js | 2 +- test/parallel/test-buffer-constants.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/buffer.js b/lib/buffer.js index cae73edde5ad9e..ac4f61bf5d0849 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -47,7 +47,7 @@ exports.kMaxLength = binding.kMaxLength; const constants = Object.defineProperties({}, { MAX_LENGTH: { - value: binding.kStringMaxLength, + value: binding.kMaxLength, writable: false, enumerable: true }, diff --git a/test/parallel/test-buffer-constants.js b/test/parallel/test-buffer-constants.js index 59f5b6d0deada4..820c8dc993ed8e 100644 --- a/test/parallel/test-buffer-constants.js +++ b/test/parallel/test-buffer-constants.js @@ -2,6 +2,7 @@ require('../common'); const assert = require('assert'); +const { kMaxLength, kStringMaxLength } = require('buffer'); const { MAX_LENGTH, MAX_STRING_LENGTH } = require('buffer').constants; assert.strictEqual(typeof MAX_LENGTH, 'number'); @@ -11,3 +12,7 @@ assert.throws(() => ' '.repeat(MAX_STRING_LENGTH + 1), /^RangeError: Invalid string length$/); assert.doesNotThrow(() => ' '.repeat(MAX_STRING_LENGTH)); + +// Legacy values match: +assert.strictEqual(kMaxLength, MAX_LENGTH); +assert.strictEqual(kStringMaxLength, MAX_STRING_LENGTH);