mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
1b0d9795b6
Refs: #13836 PR-URL: https://github.com/nodejs/node/pull/18034 Refs: https://github.com/nodejs/node/issues/13836 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const buffer = require('buffer');
|
|
const SlowBuffer = buffer.SlowBuffer;
|
|
|
|
const kMaxLength = buffer.kMaxLength;
|
|
const bufferMaxSizeMsg = common.expectsError({
|
|
code: 'ERR_INVALID_OPT_VALUE',
|
|
type: RangeError,
|
|
message: /^The value "[^"]*" is invalid for option "size"$/
|
|
}, 12);
|
|
|
|
assert.throws(() => Buffer((-1 >>> 0) + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => SlowBuffer((-1 >>> 0) + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.alloc((-1 >>> 0) + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafe((-1 >>> 0) + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafeSlow((-1 >>> 0) + 1), bufferMaxSizeMsg);
|
|
|
|
assert.throws(() => Buffer(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => SlowBuffer(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.alloc(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg);
|
|
|
|
// issue GH-4331
|
|
assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFF), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg);
|