mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
buffer: remove lines setting indexes to integer value
PR-URL: https://github.com/nodejs/node/pull/52588 Refs: https://github.com/nodejs/node/issues/52585 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
b1b0233cb2
commit
bf8afe7644
@ -243,14 +243,12 @@ class Blob {
|
||||
} else {
|
||||
start = MathMin(start, this[kLength]);
|
||||
}
|
||||
start |= 0;
|
||||
|
||||
if (end < 0) {
|
||||
end = MathMax(this[kLength] + end, 0);
|
||||
} else {
|
||||
end = MathMin(end, this[kLength]);
|
||||
}
|
||||
end |= 0;
|
||||
|
||||
contentType = `${contentType}`;
|
||||
if (RegExpPrototypeExec(disallowedTypeCharacters, contentType) !== null) {
|
||||
|
21
test/pummel/test-blob-slice-with-large-size.js
Normal file
21
test/pummel/test-blob-slice-with-large-size.js
Normal file
@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
// Buffer with size > INT32_MAX
|
||||
common.skipIf32Bits();
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
const size = 2 ** 31;
|
||||
|
||||
try {
|
||||
const buf = Buffer.allocUnsafe(size);
|
||||
const blob = new Blob([buf]);
|
||||
const slicedBlob = blob.slice(size - 1, size);
|
||||
assert.strictEqual(slicedBlob.size, 1);
|
||||
} catch (e) {
|
||||
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
|
||||
throw e;
|
||||
}
|
||||
common.skip('insufficient space for Buffer.allocUnsafe');
|
||||
}
|
Loading…
Reference in New Issue
Block a user