mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib,test: do not hardcode Buffer.kMaxLength
V8 will soon support typed arrays as large as the maximum array buffer
length. This patch replaces hardcoded values related to
Buffer.kMaxLength with the actual constant.
It also fixes a test that was passing by accident.
Refs: 44b2995900
PR-URL: https://github.com/nodejs/node/pull/49876
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
parent
cc725a653a
commit
a4fdb1abe0
5 changed files with 25 additions and 25 deletions
|
@ -24,6 +24,9 @@ const {
|
|||
concat,
|
||||
getDataObject,
|
||||
} = internalBinding('blob');
|
||||
const {
|
||||
kMaxLength,
|
||||
} = internalBinding('buffer');
|
||||
|
||||
const {
|
||||
TextDecoder,
|
||||
|
@ -62,7 +65,6 @@ const {
|
|||
} = require('internal/errors');
|
||||
|
||||
const {
|
||||
isUint32,
|
||||
validateDictionary,
|
||||
} = require('internal/validators');
|
||||
|
||||
|
@ -160,8 +162,8 @@ class Blob {
|
|||
return src;
|
||||
});
|
||||
|
||||
if (!isUint32(length))
|
||||
throw new ERR_BUFFER_TOO_LARGE(0xFFFFFFFF);
|
||||
if (length > kMaxLength)
|
||||
throw new ERR_BUFFER_TOO_LARGE(kMaxLength);
|
||||
|
||||
this[kHandle] = _createBlob(sources_, length);
|
||||
this[kLength] = length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue