diff --git a/lib/internal/blob.js b/lib/internal/blob.js index e2cf4ada95fb91..76ae58db85b9eb 100644 --- a/lib/internal/blob.js +++ b/lib/internal/blob.js @@ -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) { diff --git a/test/pummel/test-blob-slice-with-large-size.js b/test/pummel/test-blob-slice-with-large-size.js new file mode 100644 index 00000000000000..639c2217db79e3 --- /dev/null +++ b/test/pummel/test-blob-slice-with-large-size.js @@ -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'); +}