Skip to content

Commit 12ba74e

Browse files
committed
buffer: fix MAX_LENGTH constant export
This was a typo and accidentally returned the wrong value. Fixes: nodejs#14819 Ref: nodejs#13467
1 parent 314217f commit 12ba74e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Buffer.prototype = FastBuffer.prototype;
7676

7777
const constants = Object.defineProperties({}, {
7878
MAX_LENGTH: {
79-
value: kStringMaxLength,
79+
value: kMaxLength,
8080
writable: false,
8181
enumerable: true
8282
},

test/parallel/test-buffer-constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require('../common');
33
const assert = require('assert');
44

5+
const { kMaxLength, kStringMaxLength } = require('buffer');
56
const { MAX_LENGTH, MAX_STRING_LENGTH } = require('buffer').constants;
67

78
assert.strictEqual(typeof MAX_LENGTH, 'number');
@@ -11,3 +12,7 @@ assert.throws(() => ' '.repeat(MAX_STRING_LENGTH + 1),
1112
/^RangeError: Invalid string length$/);
1213

1314
assert.doesNotThrow(() => ' '.repeat(MAX_STRING_LENGTH));
15+
16+
// Legacy values match:
17+
assert.strictEqual(kMaxLength, MAX_LENGTH);
18+
assert.strictEqual(kStringMaxLength, MAX_STRING_LENGTH);

0 commit comments

Comments
 (0)